What is the best way to produce a report listing the fieldname and then the
data in that field. It is a report containing only one row from a table, but
I don't want to hard code the fields since they change often.

I can get the field names dynamically like this:

$fields = mysql_list_fields("Network", "Subnets");
$num_columns = mysql_num_fields($fields);
for($ i = 0; $i < $num_columns; $i++) { echo mysql_field_name($fields,
$i); }

now is where I get confused....what I would like to happen is do a query on
a single row and put the results into mysql_fetch_assoc and during the prior
loop put the column name into the loop of the data. Something like:

$fields = mysql_list_fields("Network", "Subnets");
$num_columns = mysql_num_fields($fields);
$result  =  mysql_query("SELECT * FROM table1 WHERE ID = '$ID';
$field = mysql_fetch_assoc($result)
for($ i = 0; $i < $num_columns; $i++) {
    echo "<b>" . mysql_field_name($fields, $i) . ": </b>" .
$field[mysql_field_name($fields, $i)] . "<br>\n";

PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to