Hi, I hope I get your question right. Your problem sounds like:
Given the number of items per page, what page will an Id fall into The solution I propose is not very sophisticated but it does work for me. Say your table looks like ------------ Page 1 1 Image A 2 Image B 3 Image C ------------ Page 1 ------------ Page 2 4 Image D 5 Image E 6 Image F ------------ Page 2 ------------ Page 3 9 Image G 10 Image H 12 Image I ------------ Page 3 ------------ Page 4 14 Image J 20 Image K 22 Image L ------------ Page 4 ------------ Page 5 30 Image M ------------ Page 5 Rule: 1 page consists of 3 images. Viewer initially clicks on Image H (Id 10) from Page 3, he then flips forward 3 images which now points to Image K (Id 20). At this time, he decideds to go back to the index page, which should now displays Page 4. The variable that you'll have to keep track with is the Image Id, which is 14 for this particular case. You would do a query: SELECT ceiling (count(*) / 3) FROM table WHERE ImageId <= 14; result will be 4 You construct your query with limit like: LIMIT page * page_size, page_size which evaluates to LIMIT 4 * 3, 3 Regards, Jindo > -----Original Message----- > From: Michael [mailto:[EMAIL PROTECTED]] > Sent: Saturday, October 20, 2001 12:47 PM > To: [EMAIL PROTECTED] > Subject: finding the range of results? > > > Short version: > How do you find what position a value is in a larger query's result? > > Long version: > I have a thumbnail image viewing page that pages through search results > using LIMIT page * page_size, page_size and that table does keep id's from > all results but they are not always 1, 2, 3, 4, 5... often they are 1, 3, > 6, 7, 9, etc.. in no special pattern but in order.. there is also an image > id per each row that is not in order and again in no special pattern.. in > cases where the user has clicked an image it uses the image id to view the > image.. then when the user wants to return to browse mode it needs to > figure out what page to return to. easy.. except they can also flip > backwards and forward in the results in view mode so the page could > change. So I need to find the page which I can do if I can find the id and > it's position in the queries result. How exactly would I find the position > in the results without dumping all results and using an external > function. Something like "position = variable in array". > > *^*^*^* > Michael McGlothlin <[EMAIL PROTECTED]> > http://mlug.missouri.edu/~mogmios/projects/ --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
