Hi,
This question could easily be related to my newbieness and possible oversight of the obious, but here goes...
I would like to create a while loop that prints the COLLUMN NAME then the value for the row returned next to it. I don't want to hard code in HTML the field names for future extensibility (like if I add a collumn to that table, I don't want to have to change my code here).
I bet it's something obvious I'm missing as to HOW TO GET THE COLUMN NAMES and STORE THEM AS VARIABLE(S).
Assume I've run the query and results are stored in $results
$fields = mysql_num_fields($result);
while ($array = mysql_fetch_array($result))
{
for ($i=0; $i <= $fields; $i++)
{
$colName = [I WOULD LIKE COLLUMN NAME TO GO HERE]
printf (" %s: %s", $colName, $array[$i]);
if ( $i < $fields ) print ("\n");
}
echo "<BR>\n";
}
Obviously, I would like to assign the collumn name to $colName each iteration.
Any ideas (RTFM's gladly accepted, but you'll have to point to it for me since I haven't seen it in the man yet).
anks,
-z