473,569 Members | 2,691 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to display newly added mysql column

hi there

i have a mysql table and i want the user to add columns using a php
interface and then display the table with the newly added column. I
was thinking about putting all the columns names in a special table
but there must be another more efficient way.

as an example this is my query to display the table:
$result = mysql_query("se lect * from news");
while($r=mysql_ fetch_array($re sult))
{
$title=$r["title"];
$message=$r["message"];
//display the row
echo "$title <br> $message <br>";
}

now if the user alter the table and add a column "rank", how can i
update my query automatically so it can display the newly added row
(or column)?
thanx in advance

patricio
Jul 17 '05 #1
2 1831
ki*********@yah oo.com wrote:
now if the user alter the table and add a column "rank", how can i
update my query automatically so it can display the newly added row
(or column)?


You can use the SQL "SHOW COLUMNS FROM table" to get all of the columns
in your table, and then loop on that array.
--
Elliott C. Bäck
http://elliottback.com/
Jul 17 '05 #2
On 20 Aug 2004 12:30:06 -0700, ki*********@yah oo.com wrote:
hi there

i have a mysql table and i want the user to add columns using a php
interface and then display the table with the newly added column. I
was thinking about putting all the columns names in a special table
but there must be another more efficient way.

as an example this is my query to display the table:
$result = mysql_query("se lect * from news");
while($r=mysql _fetch_array($r esult))
{
$title=$r["title"];
$message=$r["message"];
//display the row
echo "$title <br> $message <br>";
}

now if the user alter the table and add a column "rank", how can i
update my query automatically so it can display the newly added row
(or column)?


As you're doing "select *" you've already got it in the $r array. Use a
foreach loop to loop over the columns.

--
Andy Hassall / <an**@andyh.co. uk> / <http://www.andyh.co.uk >
<http://www.andyhsoftwa re.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2164
by: Stephen Harris | last post by:
I downloaded: Windows Binaries PHP 5.0.4 zip package - 31 Mar 2005 md5: fff10991a8e6f3b36ee567eb236ae3f4 This is the current BETA release of version 5.0 of the MySQL database server. apache_2.0.54-win32-x86-no_ssl.exe 16-Apr-2005 15:13 7.8M Installer Pack
8
7896
by: Ashish Shridharan | last post by:
Hi All I have been trying to add a control to the header cell of a datagrid on my ASP.NET page. These controls are defined in the HTML as ASP.NET web controls. They are being added into the header of the datagrid in the "ItemDataBound" method of the grid. However, once, they are added in the grid, i seem to lose the event handler for the...
0
1641
by: sjonnalagadda | last post by:
Hello All, By default Mysql select statement displays column names header only once at the first row. I want the column names for the select statment to be displayed after every say 15 rows of display. ( This is very much equal to set line size 15 in oracle) . can any one Help ASAP. Thanks in Advance.
3
1554
by: damezumari | last post by:
I am using WinXP and MS Access 2003. I have a list whose row source is an sql. I insert a new record to the table the sql takes its data from. I requery the list and the new record appears. Problem: As soon as I have done the requery I want the newly added element be highlighted in the list. How do I do that? Regards,
18
3329
by: Alpha | last post by:
Hi, I'm working on a Windows applicaton with VS 2003 on windows 2000. I have a listbox that I have binded to a dataset table, "source" which has 3 columns. I would like to display 2 of those columns, "scode" and "sname", as 1 column (if not possible then 2 columns will be fine) in the listbox. Can the listbox display 2 columns information...
1
7902
by: mike | last post by:
I have a datagridview control and a button on the windows form. I am adding a new row in button click event. When the number of rows grow, the newly added row will not be visible but a scroll bar will be shown. I want the program to highlight the newly added row and make it visible in the datagridview by scrolling to that position when a...
4
1274
by: suma2006 | last post by:
Hi All, I have one table for that i want to add one more column and making that column as foreign key to some other table.How can i do that?can any one give the syntax? here i know the syntax for adding a column: ALTER TABLE <table_name> ADD COLUMN <column_name> <datatype> Regards, Suma
6
38477
Atli
by: Atli | last post by:
This is an easy to digest 12 step guide on basics of using MySQL. It's a great refresher for those who need it and it work's great for first time MySQL users. Anyone should be able to get through this without much trouble. Programming knowledge is not required. Index What is SQL? Why MySQL? Installing MySQL. Using the MySQL...
2
2361
nev
by: nev | last post by:
i place values in a new row programatically. it has an auto-increment column. after adding the entries i do... bindingsource.endedit() tableadapter.update(dataset.datatable) the saving process has no problem. now, i want to get the value of the new record's auto-increment column. if i do this... textbox.text =...
0
7698
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...
0
7924
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. ...
0
8122
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...
0
7970
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6284
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5513
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...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3640
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1213
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.