473,789 Members | 2,634 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

show table using select statements

27 New Member
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='#eeeee e' align='left'>
<tr height="20">
<td width="10%" class="TableFie ld">Id</td>
<td width="10%" class="TableFie ld">Field</td>
<td width="60%" class="TableFie ld">Data type</td>
<td width="15%" class="TableFie ld">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='#fffff f'>
<td width="10%" class="TableFie ld"><?php echo $i; ?></td>
<td width="60%" class="TableFie ld"><input type="text" id="altertable " class="SInputTB " value="<?php echo $row['field']; ?>"></td>
<td width="60%" class="TableFie ld"><input type="text" id="altertable " class="SInputTB " value="<?php echo $row['type']; ?>"></td>
<td width="20%"><a href="javascrip t:save_data(<?p hp echo $id; ?>)">Alter</a>&nbsp;
<a href="javascrip t:requestInfo(' <?php echo $modulepath; ?>altertable.ph p','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(arra y(
'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.$template path.'altertabl e.phtml'; ?>[/PHP]
Sep 10 '07 #1
0 2076

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

Similar topics

14
4301
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 salvage the records from the many table and without going into detail, one of the reasons I can't do the opposite as there are records in the ONE table that I need to keep even if they don't have any child records in the MANY table. Below I created...
12
7702
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 million rows and if I do a select * then I do get 1 million rows. I want to be able to provide page navigation as google does, page
4
13070
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 column names in a FROM clause. After many hours or reading all manner of manuals I've discovered it appears this is not possible and that in order to so I need to further venture into dynamic SQL. My present procedure is based on all static SQL...
1
3484
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 count_big(*) from sys.objects s1, sys.objects s2, sys.objects s3, sys.objects s4, sys.objects s5 PRINT GETDATE()
7
6993
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 into the GUI because it is hard to describe in text. First of all what is the purpose of ALTOBJ()? This procedure was created mostly for ISVs who need to do produce change scripts to upgrade application from release to release, but it can also
4
1820
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 with a new table that lists deposits and the dates they are due. What I need is to print, for each record in the view, the due date for the next deposit due and the total of all payments that they will have made by the next due date.
9
5003
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 containing important values for calculation. I run various sum calculations on various fields in order to retrieve cost calculations ...etc.
4
3130
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 can speed up the processing substantially? as it currently takes about 10 minutes and thats just way too long because there is many of these imports that I need to do.... I currently insert each record one by one and I imagine thats where all the...
1
2575
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 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 " unlike the other page where i...
0
9663
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9511
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10404
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10195
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10136
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7525
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5548
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3695
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2906
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.