I found this great example which takes an sql statement and dynamically adds the field names into a header row and the data into the following rows?
Heres the example http://www.weberdev.com/get_example-4249.html
I found this great example which takes an sql statement and dynamically adds the field names into a header row and the data into the following rows?
Heres the example http://www.weberdev.com/get_example-4249.html
Since HTML tables must be written out by row, you'll have to read all the data before you're able to write out your table.
$rows = array();
while ($row = mysql_fetch_assoc($result)) $rows[] = $row;
// We'll use the first row to get the field names:
foreach($rows[0] as $field => $throwaway) {
echo '<tr>';
echo '<td>' . htmlspecialchars($field) . '</td>';
// And for each field iterate through ALL rows:
foreach($rows as $row) {
echo '<td>' . htmlspecialchars($row[$field]) . '</td>';
}
echo '</tr>';
}