Lee Stevens
11-18-2007, 07:46 PM
Hi im writing a script wich i would like to display 3 pruducts in a row.
The code below works if there is 3 items per row. but i still need it to end the div even if theres only 1 or 2
$i = 0;
while ($row = mysql_fetch_array($result))
{
extract($row);
if ($i % $itemsPerRow == 0) {
$prod .= '<div id="modules">'; // Start main class
}
$prod .= '<div id="mod'. $i .'">' . // sub class
'<div class="padding">' .
'<div class="text">' .
'<b><a href="#" title=""></a></b>' .
'<p></p>' .
'</div>' .
'</div>' .
'</div>';
$i += 1;
if ($i % $itemsPerRow == 0)
{
$i = 0;
$prod .= '</div>'; // Close class full row or not
}
}
The code below works if there is 3 items per row. but i still need it to end the div even if theres only 1 or 2
$i = 0;
while ($row = mysql_fetch_array($result))
{
extract($row);
if ($i % $itemsPerRow == 0) {
$prod .= '<div id="modules">'; // Start main class
}
$prod .= '<div id="mod'. $i .'">' . // sub class
'<div class="padding">' .
'<div class="text">' .
'<b><a href="#" title=""></a></b>' .
'<p></p>' .
'</div>' .
'</div>' .
'</div>';
$i += 1;
if ($i % $itemsPerRow == 0)
{
$i = 0;
$prod .= '</div>'; // Close class full row or not
}
}