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
- Re: [PHP-DB] Extracting column names from a db David Rice
- Re: [PHP-DB] Extracting column names from a db Ignatius Reilly
- Re: [PHP-DB] Extracting column names from a db Marco Tabini