Getting the page a picture is on using its ID

Ledeskask

New Member
I have a database containing 40 pictures. These pictures are displayed using a pager.I have a URL query: \[code\]http://www.test.com/photo.php?id=15\[/code\]. 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\[code\]select * from photo limit 40\[/code\]PHP\[code\]$i=1;while($r){if($r[id]=$id) $cur_picRank = $i;$i++;} $curPage = ceil( $cur_picRank / $pagesize);\[/code\]Is this correct?
 
Back
Top