473,406 Members | 2,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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 2551
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

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

Similar topics

3
by: jason | last post by:
If one has a series of price reduction fields (3) and corresponding date fields (3) in each record.....how would one check the row to see which of these fields contain non-null or non-empty...
1
by: Dixie | last post by:
I wish to add some fields to an existing table in code. I am using the following code from rkc. CurrentDb.Execute ("ALTER TABLE MyTable ADD MyNewField Text 25") This works , but I need to also set...
3
by: JDiamond | last post by:
Hi, I have a table called Hosts. The Hosts table contains the following fields: Each field represents a step in the project. The tech that completes each step initials the respective...
1
by: Aaron West | last post by:
Try this script to see what queries are taking over a second. To get some real output, you need a long-running query. Here's one (estimated to take over an hour): PRINT GETDATE() select...
5
by: mike | last post by:
Question. I have a new table that I am adding to a script that I wrote. This table has 3 fields, the first 2 fields are used in the on statement as being = other fields in the script. The...
9
by: Mohd Al Junaibi | last post by:
Hello all, my first post here...hope it goes well. I'm currently working on stored procedure where I translated some reporting language into T-SQL The logic: I have a group of tables...
0
by: bimeldip | last post by:
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...
10
by: H | last post by:
Hi, I have the following address fields in a table: flat_number house_name_or_number street village postal_town county postcode
3
by: janetopps | last post by:
I have a news website, with asp pages, which was on Access, and i upgraded to MySQL, i used Bullzip to transfer the data. It had about 1000 pages, which im now able to pull up on the public side. Im...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.