[thelist] sql query php layout
Howard Cheng
howcheng at ix.netcom.com
Mon Nov 25 15:38:01 CST 2002
I've done a number of these guys. Try something like:
<table width="100%" border="0" cellspacing="5" cellpadding="0">
<?
define("ITEMS_PER_ROW", 3);
$cell_width = 100 / ITEMS_PER_ROW;
$count = 0;
while ($myrow = mysql_fetch_array($result))
{
if ($count == 0) { ?>
<tr valign="top">
<? } ?>
<td width="<?= $cell_width ?>%">
<!-- DISPLAY ITEMS HERE -->
</td>
<?
$count++;
if ($count == ITEMS_PER_ROW)
{
$count = 0; ?>
</tr>
<? }
}
// end of result set, fill in extra blank cells if necessary
if ($count % ITEMS_PER_ROW > 0)
{
for ($i=0; $i<(ITEMS_PER_ROW - $count); $i++) { ?>
<td> </td>
<? } ?>
</tr>
<? } ?>
</table>
At 09:23 PM 11/25/2002 +0000, Andrew Maynes wrote:
>I am not sure I followed this exactly! I am getting the results displayed
>like
>this
>http://www.hificollective.co.uk/books/book_listing.php
>
>and success at getting them displayed like this
>http://www.hificollective.co.uk/
>
>
>
>appears to be fuitless. If there is an online article for this that would be
>great
>
> >>how do you decide how to lay out the 2 x 3?
>
>displying 1-6 of 9
>record1 record2 record3
>record4 record5 record6
> >> next results >>
::::::::::::::::::::::::::::::::::
Howard Cheng
http://www.howcheng.com/ <-- NEW!
howcheng at ix dot netcom dot com
AIM: bennyphoebe
ICQ: 47319315
More information about the thelist
mailing list