About Next Previous Links
Posted: Thu Feb 24, 2005 7:53 pm
Hi Everyone been a while since I Posted! I am running a very simple gallery script but there is a few errors in the code that I am having problems working out. The first problem is it won't display the correct amount of images. If I want to display 9 images I have to set the variable at 11. Second the next link is always there and continues to count up and up and up
anyhelp with this script would be very much appreciated
anyhelp with this script would be very much appreciated
Code: Select all
<?php
$a = 0;
$new_tr = 0;
$filepath = "abstractthumbs";
$url_path = "abstract";
$dir = dir($filepath);
$start=0;
$stop=11;
if(!empty($_GETї'start']) && !empty($_GETї'stop'])) {
$start=intval($_GETї'start']);
$stop=intval($_GETї'stop']);
}
echo "<table width="600" border="0" cellpadding="5"
cellspacing="5">";
while($entry=$dir->read()) {
if($a>=$start && $a<$stop) { // $a<$stop because from 0-19 you have 20
pictures
if($entry != "." && $entry != "..") {
if (!($new_tr%3)) {echo "<tr>";}
?>
<td align="center" valign="middle">
<a href="abstractpics.php?image=<?php echo urlencode($entry); ?>">
<img src="<?php echo "$filepath/$entry"; ?>" alt="<?php echo $entry; ?>"
border="1" class="imgborder"></a>
</td>
<?php
$new_tr++;
if (!($new_tr%3) && $new_tr!=0) { echo "</tr>"; }
} // end of if($entry
} // end of if($new_tr>=
$a++;
} // end of while
?>
</td>
</tr>
</table>
<table width="600">
<tr align="center">
<td>
<?php
if($start>=9) {
$start2=$start-9;
echo "<a
href="".$PHP_SELF."?start=".$start2."&stop=".$start."">previous</a>";
}
echo " ";
if ($stop != 0) {
$stop2=$stop+9;
echo "<a href="".$PHP_SELF."?start=".$stop."&stop=".$stop2."">next</a>";
}
?>
</td>
</tr>
</table>