I think you want the column headers right??
Header1 header2 header3 <<---- this is what you want right?
data1 data2 data3
data4 data5 data6
echo '<!-- Results Table Header Field Names -->';
for ($k = 0; $k < sizeof($l_row) ; $k++)
{
echo "\t" . '<td>';
echo mysql_field_name($l_results,$k);
echo "</td> \n";
}
As someone pointed out to me, remember to reset your pointer back to 0, else
you'll only get output from row 2 (data4,5 & 6) as the pointer is alreadly
incremented by 1.
use -> mysql_data_seek($l_results,0);
Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia
DID : 03-7870 5168
-----Original Message-----
From: Jackson Miller [mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 23, 2003 10:56 PM
To: Jake Johnson; Mysql
Subject: Re: How do I show column names in php?
Try:
$result = mysql_query("SHOW COLUMNS FROM table_name");
while ($row = mysql_fetch_array($result)) {
foreach ($row as $key=>value) {
echo "$key = $value";
}
}
-Jackson
On Wednesday 23 July 2003 9:32, Jake Johnson wrote:
> I am using php and mysql and I want to show the column names. How do I go
> about doing this without hardcoding the headers in my php?
>
> Regards,
> Jake Johnson
> [EMAIL PROTECTED]
>
> ______________________________________________________________________
> Plutoid - http://www.plutoid.com - Shop Plutoid for the best prices on
> Rims, Car Audio, and Performance Parts.
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]