Jump to content

Retrieving field names and values from database


PeggyBuckham

Recommended Posts

I want to retrieve the field names from a database with the associated values. I know how to retrieve the values but haven’t figured out how to get the field names. Here is the code I use to get the values. 

 

$sql='SELECT * FROM table WHERE table_id =' .$id;

$result = mysql_query($sql,$db) or die(mysql_error(). "<br/>SQL: $sql");

$row = mysql_fetch_array($result);

 

if($row){

foreach ($row as $key => $value){

if(!empty($value)){

print '<p>'.$value.'</p>';

}

}

}

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.