Re: How to display database table data in a html table.
- From: Arjen <dont@xxxxxxx>
- Date: Fri, 26 Jan 2007 18:46:59 +0100
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
.
- Prev by Date: Function execution before page reload
- Next by Date: Please Kindly, CD needed ()
- Previous by thread: Function execution before page reload
- Next by thread: Re: How to display database table data in a html table.
- Index(es):
Relevant Pages
|
|