Need to <div> for every 4 blocks, and </div>...how?
Posted: Tue Jun 24, 2014 5:28 am
I'm trying to do a gallery here, and it shows each block of four images at a time.
So it needs to be:
This isn't working. It's putting </div> when I dont want them, and then missing <div>.
I'm sure it's done with a count, and then I would have thought it's every four rows.
So it needs to be:
Code: Select all
<div>
<img><img><img><img>
</div>
<div>
<img><img><img><img>
</div>Code: Select all
<div style='left: -680px;' class='items'>";
$string = "$row->photo";
$token = strtok($string,"|");
$c1 = 1;
$n1 = 5; // Each Nth iteration would be a new table row
while($token) {
if ($c1 == "1") { echo "<div>";}
if($c1 % $n1 == 0 && $c1 != 0) // If $c1 is divisible by $n1...
{
echo "<div>";
}
echo "
<a href='/images/productphotos/$token' rel=\"zoom-id:Zoomer;\" rev='/images/productphotos/$token' title='$row->title' /><img src='/images/productphotos/small/$token' border='0' /></a>";
if($c1 % $n1 == 0 && $c1 != 0) // If $c1 is divisible by $n1...
{
echo "</div>";
}
$token = strtok("|");
$c1++;
}
echo "</div>