Forum Moderators: coopster
The script shows 5 thumbs per page. When you click "next" you get the next 5 thumbs.
The problem is this: If you click to a second or 3rd page of thumbnails, and then click one of the thumbs to enlarge, the page goes back to page ONE of the thumbs. I would like the page to remain on the 2nd or 3rd page of thumbs, whereever the user happens to be.
Is it possible to look at this script to determine where the issue is and what code I can tweak to make it post to itself and remain where it is without reverting to the page one of thumbnails?
Thanks very much.
<?PHP
// rows to return
$limit=5;
$date = date("Y-m-d");
$title =$row['title'];
$summary =$row['summary'];
$news_id = $row['news_id'];
$thumbnail = $row['thumbnail'];
$title = $row['title'];
$query = "select * from photo_gallery where category_id = 1
order by photo_id desc";
$numresults=mysql_query($query);
$numrows=mysql_num_rows($numresults);
if (empty($s)) {
$s=0;
}
$query .= " limit $s,$limit";
$count = 1 + $s ;
$results=mysql_query($query) or die (mysql_error());
while ($rows=mysql_fetch_array($results)) {
extract ($rows);
echo " <a href='http://www.example.com/new/architecturalgallery.php?photo_id=$rows[photo_id]'>";
echo "<img src='http://www.example.com/oneadmin/_files/photogallery/$thumbnail' width=75 height=50 border=1>";
echo "</a>";
echo " ";
$count++ ;
}
$currPage = (($s/$limit) + 1);
//break before paging
echo "<br />";
if ($s>=1) { // bypass PREV link if s is 0
$prevs=($s-$limit);
print " <a href=\"$PHP_SELF?s=$prevs&q=$var\"><<
Prev 5</a>  ";
}
$pages=intval($numrows/$limit);
if ($numrows%$limit) {
$pages++;
}
if (!((($s+$limit)/$limit)==$pages) && $pages!=1) {
$news=$s+$limit;
echo " <a href=\"$PHP_SELF?s=$news&q=$var\">Next 5 >></a>";
}
$a = $s + ($limit) ;
if ($a > $numrows) { $a = $numrows ; }
$b = $s + 1 ;
?>
[edited by: eelixduppy at 2:38 pm (utc) on May 13, 2007]
[edit reason] use example.com for exemplification, thanks [/edit]
Say you have 15 images at 5 per page and the visitor is on image 12. You'll need to know that image 12 shows up on thumbnail page 3. Off the top of my head the math is ceil($current_position / $total_images) so image 12 would be ceil(12/15) which is 3.
Edit...
Thought of another idea. You could also pass the page number as a variable from the thumbnail page to the fullsized and then just use that variable. Something like /index.php?p=fullsize&page=3.
[edited by: Nutter at 4:01 pm (utc) on May 13, 2007]
Any takers?