![]() |
|
[DBMS] SQL - Limits not working - limits doubling. - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Coders Lounge (https://hackforums.net/forumdisplay.php?fid=5) +---- Thread: [DBMS] SQL - Limits not working - limits doubling. (/showthread.php?tid=5105848) |
SQL - Limits not working - limits doubling. - Skidy - Dec 23, 2015 So I have been experimenting with a SQL paginator. My SQL query is this: [img]http://screenshu.com/static/uploads/temporary/jy/0p/ce/tiqavq.jpg[/img] On the first page it displays 10 results, on the second page it displays 20 results, on the third page it displays 30 results. The results are not the same but new results that range. Page 1: [img]http://screenshu.com/static/uploads/temporary/wu/53/on/ajjlk7.jpg[/img] Page 2: [img]http://screenshu.com/static/uploads/temporary/42/x3/2n/luv0zd.jpg[/img] And so on. Why is this happening? * - .eXe - Dec 25, 2015 In your while statement you have Code $limit = $limit + 10So surely, every time you're clicking next, that is just adding 10 to the limit range. * - Leather - Dec 30, 2015 Hi, I think you got the usage of LIMIT wrong. Code Select * from countries ORDER BY country LIMIT 10,20 ;The above statement will basically return you the 20 results after the 10th element. Please try the following code Code 'Select * from countries ORDER BY country LIMIT '.($limit - 10) .',10'in the $db->query() statement. I'm no expert in programming and using this platform to learn myself so I apologize in advance if this doesn't help you. Hope this helps though. Good luck; Leather. |