Extracting column names from a db

From: Date: Sun, 10 Nov 2002 15:18:09 +0000
Subject: Extracting column names from a db
Groups: php.db 
Request: Send a blank email to php-db+get-23181@lists.php.net to get a copy of this message
I need to write a script that will extract the names of the columns in my database eg. "user_id, username" can anyone help as to how to do this! I have tried ************************************************** *********** mysql_select_db("filterseveuk") or die(mysql_error()); $query = "SHOW COLUMNS FROM " .$table. ""; $result = mysql_query ( $query ) or die( mysql_error () ); $numrows = mysql_num_rows ($result); $row = mysql_fetch_array ($result); for($x=0; $x <= $numrows; $x++){ echo $row[$x] ; } ************************************************** *********** this doesn't work the way i want it to and gives me the output ************************************************** *********** user_idint(11)PRIauto_increment Warning: Undefined offset: 6 in /home/filterseveuk/public_html/admin/index.php on line 30 Warning: Undefined offset: 7 in /home/filterseveuk/public_html/admin/index.php on line 30 Warning: Undefined offset: 8 in /home/filterseveuk/public_html/admin/index.php on line 30 Warning: Undefined offset: 9 in /home/filterseveuk/public_html/admin/index.php on line 30 Warning: Undefined offset: 10 in /home/filterseveuk/public_html/admin/index.php on line 30 Warning: Undefined offset: 11 in /home/filterseveuk/public_html/admin/index.php on line 30 Warning: Undefined offset: 12 in /home/filterseveuk/public_html/admin/index.php on line 30 Warning: Undefined offset: 13 in /home/filterseveuk/public_html/admin/index.php on line 30 Warning: Undefined offset: 14 in /home/filterseveuk/public_html/admin/index.php on line 30 _________________________________________________________________ Tired of spam? Get advanced junk mail protection with MSN 8. http://join.msn.com/?page=features/junkmail

« previous php.db (#23181) next »