Posted by Arjen on 01/26/07 17:46
McGowan schreef:
> Hi, I'm trying to display data from a mysql database in a HTML table
> but for some reason my code isn't working. At the moment I have got it
> to read and display the headers and the first row of the table and it
> actually creates the remaining rows in the html table but it doesn't
> put any data in them. This is my code so far:
I used this code once ... There are faster ways but I really dont use
tables anymore so I never rewrote the code.
// table top
echo '<table width="800">';
// first row contains table headers (not using th)
echo '<tr>';
foreach ($allheaders as $header)
{
echo '<td>'.$header.'</td>';
}
echo '</tr>';
// the data
foreach ($alldata as $data)
{
echo '<tr>';
foreach ($allheaders as $field)
{
// field is filled
if ($data[$field])
{
echo '<td>'.$data[$field].'</td>';
}
// empty field
else
{
echo '<td> </td>';
}
}
echo '</tr>';
}
echo '</table>';
--
Arjen
http://www.hondenpage.com
Navigation:
[Reply to this message]
|