LIMIT $start, 10... how to pass last value queried into next page with GET??


Posted on 16th Feb 2014 07:03 pm by admin

Ok I know how to display the first or last 10 results of a query...

$result = mysql_query("SELECT * FROM messages ORDER BY timemsg DESC LIMIT 10");

In a perfect world all the rows ID's would be in perfect order (i.e.- 10,9,8,7,6,5,4,3,2,1), so to display messages 30 to 40 I would just do LIMIT 30,10
but because of certain unforseen situations the actual results will end up being more like-
457
455
454
453
449
448
447
419
418
410

So I can display the last 10 results in descending order but then to show the "previous 10" results (using the above numbers for an example), I'm thinking I need to somehow
capture the last result in this query (410) so when you hit "previous 10" link it passes it through GET to the next page and the next page will use something like LIMIT $start,10
to display the 10 results with before "410" and so on. Any idea how to do this, I don't think it should be that hard, just can't figure it out. Sorry, if this is in wrong thread,
feel free to move to MYSQL board if it belongs there.. Thanks for any help!

No comments posted yet

Your Answer:

Login to answer
72 Like 13 Dislike
Previous forums Next forums
Other forums

Preserving user-entered linebreaks
Hi, I'm building a web 2.0 thingy from scratch and I wanna display text which users input. It's all

Adding Outlook 2007 items via file upload
I am looking for a way to be able to attach an Outlook item (an email message) in an ASP.NET 3.5 app

[Need Help] php timing issues
I don't know what is going wrong. I need some help with being able to set an image at 9:00am Colorad

Change Age automatically
hi guys . im new to php , is it possible to change age value in mysql automatically when year change

Alterar a hora do servidor
Se alguém souber, ajude-me a adicionar 6 horas, obrigado
<tr>
&

Pop-up Banner
Hello Friends,I need to use banner in our client site.Example: www.example.com if i enter this site

Disable html within defined tags
I have a mysql database that allows users to enter content with html, but I also want to have a tag

using file_get_contents??
okay how would i create a script using file_get_contents() in php have it grab search pages 1-20 and

Update data to upper case in parent/child tables
Hi Gurus!

In production we have a product table and which is being reference by many tabl

LOOPing Problem
Hello All!

The following code loops through the data and displays the data accordingly. My p

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash