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!

72 Like 13 Dislike
Previous php-forum Next php-forum
Other php-forum

Hyperlink is adding an extra gap to variable
Hi, here's my problem..

I have a php generated page with a hyperlink which opens in a new win

PHP XML extraction text
I would like to extract an xml text and have that text directly echo(print) out on my web page. Her

Must-Know Topics of PHP
Can you guys list the must-know topics of PHP. I am still a learner and I am trying to cover most of

Variable passed to each() is not an array or object
Hi,

This is a email a friend type of form, and it isn't working anymore.

<?

Count Session and Trigger Events
I am New in PHP, seeking a method to count logged users by counting the sessions or any …, is

Check Date/Time in PHP
What I need the code to check is that $reQuest is 24 hours in the past then return a time based on h

Need help making a blockquote and line items conditional
I have some code I bought a few years ago that allows my clients to update content on their site usi

array_combine() trouble w/csv file
I have a problem with a piece of code I wrote to import some records from a csv file into mysql. I h

Undefined variable when using $_SERVER['PHP_SELF']
Hi guyz, please suggest me something...
On first.php I have one input field NAME, and on posting

my sql select id and then update problem.
I need to select some auto incremented ids out of a database and then use those id in a where statem

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