...

View Full Version : list all fields



jdimino
02-18-2006, 10: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

fci
02-18-2006, 10:52 PM
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, 11: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, 11: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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum