469,307 Members | 2,131 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,307 developers. It's quick & easy.

show fields using select statements

Hi,
I have managed to create codes to display data from the database in a html page.I have gone on to create a page to allow users to manipulate the table via a html page. For instance users will be able to change field name or data type of field
But the problem that i'm facing currently is that i am unable to display the list of fields on the html page.
i'm guessing its because i'm using "show fields from [tablename]" unlike the other page where i used standard select statements.

So the way i see it...is that i either find a way to display the fields of a table using select statement?
OR
i learn a way to manipulate the show statement making sure the list of fields are displayed.
So far at the phtml page is as below:
Expand|Select|Wrap|Line Numbers
  1. <table width='550' style="margin-left:8px;"  border='0' cellpadding='0' cellspacing='1' bgcolor='#eeeeee' align='left'>            
  2.             <tr height="20">
  3.                 <td width="10%" class="TableField">Id</td>
  4.                 <td width="10%" class="TableField">Field</td>
  5.                 <td width="60%" class="TableField">Data type</td>
  6.                 <td width="15%" class="TableField">Action</td>
  7.             </tr>
  8.             <?php
  9.                 while ($row = $stmt->fetch()) {    
  10.                     $id = $row['id'];
  11.                     $field_ = $row['field'];
  12.                     $type = $row['type'];
  13.                     $i = $i + 1;
  14.             ?>
  15.             <?php
  16.                 if ($mode == "edit")
  17.                 {    
  18.                     if($id_==$id)
  19.                     {
  20.             ?>
  21.                         <tr bgcolor='#ffffff'>
  22.                             <td width="10%" class="TableField"><?php echo $i; ?></td>
  23.                             <td width="60%" class="TableField"><input type="text" id="altertable" class="SInputTB" value="<?php echo $row['field']; ?>"></td>
  24.                             <td width="60%" class="TableField"><input type="text" id="altertable" class="SInputTB" value="<?php echo $row['type']; ?>"></td>
  25.                             <td width="20%"><a href="javascript:save_data(<?php echo $id; ?>)">Alter</a>&nbsp;
  26.                                 <a href="javascript:requestInfo('<?php echo $modulepath; ?>altertable.php','login','')">Cancel</a></td>
  27.                         </tr>
and the php page is as below:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.     $altertable = $_GET['altertable'];
  3.     $field = $_GET['field'];
  4.     $mode = $_GET['mode'];
  5.  
  6.     $db = new Zend_Db_Adapter_Pdo_Mysql(array(
  7.         'username' => 'root',
  8.         'host'     => $host,            
  9.         'password' => '',
  10.         'dbname'   => 'test'
  11.     ));
  12.  
  13.     if ($mode == "save")
  14.     {
  15.         $data = array(
  16.             'field' => $member
  17.  
  18.  
  19.         );    
  20.         $n = $db->alter('member', $data, 'field = "'.$field.'"');            
  21.     }
  22.  
  23.     if ($mode == "delete")
  24.     {        
  25.         $n = $db->delete('member', 'field = "'.$field.'"');        
  26.     }
  27.  
  28.     if ($mode == "add")
  29.     {        
  30.         $data = array(            
  31.             'field' => $member
  32.  
  33.         );
  34.  
  35.         $s=$db->alter('member', $data, 'field = "'.$field.'"');        
  36.     }
  37.     $stmt = $db->query('show fields from member');
  38. ?>
  39. <?php require $root.$templatepath.'altertable.phtml'; ?>
Sep 3 '07 #1
1 2369
pbmods
5,821 Expert 4TB
Heya, Bimeldip.

You posted this in the Articles section. I'll go ahead and move it to the Forum where an Expert will be more likely to find it.

I award 4 points for creative use of [quote] tags. Unfortunately, I must deduct 4 points for not using [code] tags. Better luck next time.

Please use CODE tags when posting source code. See the REPLY GUIDELINES on the right side of the page next time you post.
Sep 3 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Dixie | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.