jdimino
02-18-2006, 09:29 PM
Hi
I'm looking for a script to list all fields in mysql database table, can someone show me a typical code or a link where I can get such info.
Regards JD
if you use phpmyadmin, you can view the data dictionary which shows you that information. it is at the bottom of the table list in the right-hand frame.
Kid Charming
02-18-2006, 10:02 PM
Just run this query
SHOW COLUMNS
FROM
tablename
The column names will be returned in a column called 'Field':
while( $row = mysql_fetch_assoc($result) )
{
echo $row['Field'];
}
goughy000
02-18-2006, 10:16 PM
<?php
mysql_connect("localhost", "root", "psswd");
mysql_select_db("database");
$result = mysql_query("SHOW COLUMNS FROM table");
while($field = mysql_fetch_array($result)){
echo $field[Field];
echo "<br />";
}
?>
EDIT: Wups, Kid Charming beat me to it