What I'm trying to do is display all the pictures in a specific album, but I want to show exactly three across in a row. I'm using a while loop to check for pics (code below), but I don't know how to cycle that while loop so that three pics are on the same row and every fourth starts a new one.
How can I set this up using PHP, CSS, etc. so that I have exactly three columns per row, and as many rows as necessary? Here's what I've got so far:
$result_pics = mysql_query("select * from pics where pic_album='" . $album_name . "'");
while ($row_pics = mysql_fetch_array($result_pics)) {
echo "<div class='pic_cont'>" .
$row_pics['pic_filename'] . "
</div>
";
}
Is there a way to specify which $row_pics rows are selected? Something like $row_pics[1]['pic_filename'] so that I could then use an increasing integer? This is what I'm trying to do, but can't get to work:
$i = '0';
while ($row_pics = mysql_fetch_array($result_pics)) {
echo "<div class='pic_cont1'>" .
$row_pics[i]['pic_filename'] . "
</div>";
$i = $i + 1;
echo "<div class='pic_cont2'>" .
$row_pics[i]['pic_filename'] . "
</div>";
$i = $i + 1;
echo "<div class='pic_cont3'>" .
$row_pics[i]['pic_filename'] . "
</div>
<br>";
$i = $i + 1;
}
I need to get that line-break after every third pic, and only after every third pic. How?

New Topic/Question
Reply




MultiQuote



|