Okay so I have a list of 20 images, I want to display 5 per page, the code I 
have included will do that without any problems, and the code I have included 
will setup the Prev, Next and page # links and they will pull up the correct 
results.  However I need to include some functionality where if I give this 
code an image id say 13, that the code with then show 13 as the first one and 
go on to 14, 15 to the end, and then start over ending the list at 12.  So 
that in this example you have 13, 14, 15, 16, 17 on page 1.  page 2 would have 
the next 5 and so on back to 12. 

So I need to order a list starting at x, which in this case = 13, and then 
have it loop around and end at 12.

Quoting [EMAIL PROTECTED]: 

> This is a little bit more involved then the subject would let on.  What I 
> have 
> is a picture page, has nothing to do with an 80's themed kids show starring 
> 
> Bill Cosby, but what it has to deal with is a search results like page where 
> 5 
> images will appear with a next and prev link to get to more.  However what I 
> 
> need to do extra is if someone clicks in from a link for a particular 
picture 
> 
> I need to display that pic first.  So below is my psudocode. 
> 
> $numresults = mysql_query("SELECT * FROM images WHERE approved = 1"); 
> $numrows = mysql_num_rows($numresults); 
> if (empty($offset)) { 
>         $offset=0; 
> } 
> // end entry 
> $sqlquery = "SELECT * FROM images WHERE approved = 1 ORDER BY imageId DESC 
> limit $offset,$limit"; 
> $result = mysql_query($sqlquery); 
> while ($search_return = mysql_fetch_array($result)) { 
>         print the images here 
> } 
> //mysql_free_result($result); 
> print $search_results; 
> // entry for results 
> $pages = intval($numrows/$limit); 
> if ($numrows%$limit) { 
> $pages++; 
> } 
> 
> for ($i=1;$i<=$pages;$i++) { 
> $newoffset=$limit*($i-1); 
> print "<a href=\"$PHP_SELF?offset=$newoffset&sc=searchResults\">$i</a> \n"; 
> 
> } 
> 
> 
> if ($offset>1) { 
> $prevoffset=$offset-$limit; 
> print "<a href=\"$PHP_SELF?offset=$prevoffset&sc=searchResults\">$Prev</a> 
> \n"; 
> } 
> 
> 
> if ($numrows>($offset+$limit)) { 
> $nextoffset=$offset+$limit; 
> print "<a href=\"$PHP_SELF? 
> offset=$nextoffset&sc=searchResults\">$Next</a><p>\n"; 
> } 
> 
> Any thoughts? 
> 
> 
> ------------------------------------------------- 
> This mail sent through IMP: http://horde.org/imp/ 
> 
> -- 
> PHP General Mailing List (http://www.php.net/) 
> To unsubscribe, visit: http://www.php.net/unsub.php 
> 


-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to