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

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("select * from news");
while($r=mysql_fetch_array($result))
{
$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 1825
ki*********@yahoo.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*********@yahoo.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("select * from news");
while($r=mysql_fetch_array($result))
{
$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.andyhsoftware.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
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....
8
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...
0
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...
3
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. ...
18
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...
1
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...
4
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...
6
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...
2
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
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,...

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.