You are here: Re: How to display database table data in a html table. « PHP Programming Language « IT news, forums, messages
Re: How to display database table data in a html table.

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>&nbsp;</td>';
}
}
echo '</tr>';
}
echo '</table>';

--
Arjen
http://www.hondenpage.com

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация