A mix-up in your loop. Try: while ( $row = mysql_fetch_array( $result ) ) { echo $row['Field'] ; } (you may just as well use the field names provided by SHOW COLUMNS - more readable than numerical indexes) HTH Ignatius ____________________________________________ ----- Original Message ----- From: "David Rice" <haloplayer@hotmail.com> To: <php-db@lists.php.net> Sent: Sunday, November 10, 2002 4:18 PM Subject: Extracting column names from a db > > > 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 > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php