hello guys, i have lots of ids saved in mysql but i want to show them on different pages in division. For example: I have 1 2 3 4 5 6 i want to show 3 on one page and the next three on other page. my query is: SELECT * FROM tablename ORDER BY id DESC LIMIT 3 now i want to show first three on first page, and the other on next page. so how can i do that? quick help would be appreciated..
I think if you do LIMIT 3,3 it has an offset of 3 and selects 3, so it would select IDs 4, 5 and 6. Then on the next page you would have LIMIT 6,3.
From the PHP script , POst a start number... For eg: if 3 displayed on first page ..... When user presses next , send number 4 .... xyz.com/index.php?startlimit=4 Then start displaying from 4th..... then do the above
Basically you construct your Limit inside the query based on this formula: $limit = 'LIMIT ' .($pageno-1) * $rows_per_page .',' .$rows_per_page; So if you want to see the records from the second page your computed limit query would be: $limit = 'LIMIT ' .(2-1)*3,3; -> $limit = 'LIMIT 3,3'; Search in Google for "mysql php pagination" for more detailed explanations and examples.
exactly this is what i wanted. thank you so much.. + goes for you. and for others, I really appreciate your quick reply. Thank you so much!!