Jump to content

get the name of the first field in a table


jeff5656

Recommended Posts

Lets say I want to get the name of the first field in a table (or the second) and assign it to a variable.

i.e., if the first fieldname in a table is called "record_number", I would want:

$first = "record_number";

 

Here's what I was able to come up with so far but not sure what to do next:

 

$sql = "SELECT * FROM $tbl ";
$result = mysql_query($sql) or die("Query failed : " . mysql_error()); 
$line = mysql_fetch_array($result, MYSQL_ASSOC);

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.