...

View Full Version : Is there a problem with my if() loop?



Noonga
02-24-2012, 08:25 AM
Does anyone know why I am not getting a new HTML table <TR> after 8 products, with this code? I can't figure it out. :shrugs:



while ($row = mysql_fetch_assoc($result)) {
echo '
<TD>
<A href="/products/'.$row['id'].'/">'.$row['id'].'</A>
</TD>
';
$listing++;
if ($listing == 8) {
echo '
</TR>
<TR>
<TD>
<BR>
</TD>
';
$listing = 0;
}
}

tangoforce
02-24-2012, 09:27 AM
Try this:



//This bit is important
$listing = 0;

while ($row = mysql_fetch_assoc($result))
{
echo <<<STOP
<TD>
<A href="/products/$row[id]/">$row[id]</A>
</TD>

STOP;

$listing++;

if ($listing == 8)
{
echo <<<STOP
</TR>
<TR>
<TD>
<BR>
</TD>

STOP;

$listing = 0;
}
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum