I have a database containing 40 pictures. These pictures are displayed using a pager.
I have a URL query: http://www.test.com/photo.php?id=15
. This sets the current picture ID to 15. This picture is the 5th one on page 2.
How can I get the page a picture is on given only the ID?
SQL
select * from photo limit 40
PHP
$i=1;
while($r){
if($r[id]=$id) $cur_picRank = $i;
$i++;
}
$curPage = ceil( $cur_picRank / $pagesize);
Is this correct?