473,320 Members | 1,936 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,320 software developers and data experts.

show table 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:

Code: ( html4strict )
[HTML]<table width='550' style="margin-left:8px;" border='0' cellpadding='0' cellspacing='1' bgcolor='#eeeeee' align='left'>
<tr height="20">
<td width="10%" class="TableField">Id</td>
<td width="10%" class="TableField">Field</td>
<td width="60%" class="TableField">Data type</td>
<td width="15%" class="TableField">Action</td>
</tr>
<?php
while ($row = $stmt->fetch()) {
$id = $row['id'];
$field_ = $row['field'];
$type = $row['type'];
$i = $i + 1;
?>
<?php
if ($mode == "edit")
{
if($id_==$id)
{
?>
<tr bgcolor='#ffffff'>
<td width="10%" class="TableField"><?php echo $i; ?></td>
<td width="60%" class="TableField"><input type="text" id="altertable" class="SInputTB" value="<?php echo $row['field']; ?>"></td>
<td width="60%" class="TableField"><input type="text" id="altertable" class="SInputTB" value="<?php echo $row['type']; ?>"></td>
<td width="20%"><a href="javascript:save_data(<?php echo $id; ?>)">Alter</a>&nbsp;
<a href="javascript:requestInfo('<?php echo $modulepath; ?>altertable.php','login','')">Cancel</a></td>
</tr>[/HTML]


and the php page is as below:

[PHP]Code: ( php )
<?php
$altertable = $_GET['altertable'];
$field = $_GET['field'];
$mode = $_GET['mode'];

$db = new Zend_Db_Adapter_Pdo_Mysql(array(
'username' => 'root',
'host' => $host,
'password' => '',
'dbname' => 'test'
));

if ($mode == "save")
{
$data = array(
'field' => $member


);
$n = $db->alter('member', $data, 'field = "'.$field.'"');
}

if ($mode == "delete")
{
$n = $db->delete('member', 'field = "'.$field.'"');
}

if ($mode == "add")
{
$data = array(
'field' => $member

);

$s=$db->alter('member', $data, 'field = "'.$field.'"');
}
$stmt = $db->query('show fields from member');
?>
<?php require $root.$templatepath.'altertable.phtml'; ?>[/PHP]
Sep 10 '07 #1
0 2048

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

Similar topics

14
by: serge | last post by:
I have a scenario where two tables are in a One-to-Many relationship and I need to move the data from the Many table to the One table so that it becomes a One-to-One relationship. I need to...
12
by: TP | last post by:
Here is my problem. I need to display a table about which I have no information except the table name. Using metadata I can somehow show the column names and record values. But my table has 1...
4
by: Tim.D | last post by:
People, I've ventured into the wonderful world of Stored Procedures. My first experience has been relatively successful however I am stuck on using host variables to specifiy actualy table or...
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...
7
by: Serge Rielau | last post by:
Hi all, Following Ian's passionate postings on problems with ALTOBJ and the alter table wizard in the control center I'll try to explain how to use ALTOBJ with this thread. I'm not going to get...
4
by: J | last post by:
I am editing a pre-existing view. This view is already bringing data from 40+ tables so I am to modify it without screwing with anything else that is already in there. I need to (left) join it...
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...
4
by: Bob | last post by:
Hi all, I'm trying to import data, modify the data then insert it into a new table. The code below works fine for it but it takes a really long time for 15,000 odd records. Is there a way I...
1
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.