Keeping loop setting
Posted: Thu Apr 24, 2003 1:10 pm
I have a minor problem in a script which should display 6 images per page, 3 per row. All works except it don't keep the 3 images per row setting on next page.
I can't figure out what i'm missing, must be something simple (always is!).
My guess is that I need to use a loop instead of if ($i==3){ echo "<BR>"; } but can't figure out quite how.
Anyway, here's a sample from my script...
Any help would be appreciated
--lunartek
I can't figure out what i'm missing, must be something simple (always is!).
My guess is that I need to use a loop instead of if ($i==3){ echo "<BR>"; } but can't figure out quite how.
Anyway, here's a sample from my script...
Code: Select all
<?
global $show;
$dir = opendir("$DOCUMENT_ROOT"."/$dirname");
$i=1;
$count=0;
$increment = $rows*$cols-1;
$begin = (!empty($_GET['show']) && is_numeric($_GET['show']) && $_GET['show'] > 0) ? $_GET['show'] : 1;
$end = $begin + $increment;
while ($filename = readdir($dir)) {
if (ereg ("(.*)\.gif", $filename)) {
if ($i >= $begin && $i <= $end) {
if ($count >= 0) {
echo "<img src="http://$SERVER_NAME/$dirname/$filename"> ";
}
if ($i==3){ echo "<BR>"; }
}
$i++;
$count++;
}
}
closedir($dir);
if ($begin!=1){
echo "<BR><a href="test2.php?show=".($begin-$increment-1)."">previous images</a>";
}
if ($end<=$count){
echo "<BR><a href="test2.php?show=".($begin+$increment+1)."">next images</a>";
}
>?Any help would be appreciated
--lunartek