IT & Programming

Display all mysql tables from a database with PHP

  1. How to display all mysql table field names.
  2. Show all mysql table field name with php.
  3. List all field names of mysql table.

This scripts list all mysql table field names.

Script

$i=0;
$sql = mysql_query("select * from products");

while( $i < mysql_num_fields($sql)){

    echo mysql_field_name($sql, $i)  .  ', ';
    $i++;
}

Output

id, product, ,item_code, category, price

Leave A comment

Email address is optional and will not be published. Only add email address if you want a reply from blog author.
Please fill required fields marked with *