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