I'm wondering if there is an easy way to draw a table using the standard while(mysql_fetch_assoc) where the left most column is the header like this:
Name | Peter Jacksson | Steven Spielberg | Martin Scorsese | Birthyear | 1961 | 1946 | 1942 | Movie | Lord of the Rings | Jurassic Park | Cape Fear |
(Rats! SO doesn't support the table-tag).
I would do this by adding the elements to an array structure and then printing that structure:
$data = array('name' => array(), 'birth' => array(), 'movie' => array());
while($r = mysql_fetch_assoc(...)) {
$data['name'][] = $r['name'];
...
}
echo '<th>Name</th>';
foreach($data['name'] as $n) {
printf('<td>%s</td>', htmlspecialchars($n));
}
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With