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

Converting RGB values to HEX
Code: <?PHP

$file_handle = fopen("colors/rgb.csv", "r");

wh

DB2 for z/OS, LUW, iSeries
Hello, In this forum a lot of threads related to other members of the DB2 family than DB2 for z/OS

Random date selection
i want to select random date with time(hour+minutes+sec) where date is specified(10/22/2009) and tim

user validation always displaying invalid ? please help
Hello,

I have 2 accounts and there is a field in mysql called validated it can be either &quo

Unifying logins of two different scripts
I have two different game scripts which I want to embed on my own site. The problem is I don't want

TemplatePower & AJAX
Hi all,



I'm currently implementing some AJAX features in my PHP-framework (which is b

same querie, or a new one??
Hi guys,

I'm still working on this drop down list. I've got the actual drop down list to wor

Code working in IE but not FireFox
I created a dynamic navigation list for my website based off of a table in my database. The code is

quick question
Hi ..

i have a question
how do i set a var so it displays via an echo
Code: $logo = '&a

How to have a log of all the status a VIM document had been ?
Hi guys,

I’m using SAP Invoice Management plugin and the /OPT/VIM_ANALYTICS transa

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