Rommeo Posted April 11, 2010 Share Posted April 11, 2010 in my table datas are like : 1 2 3 4 print_page(0,2) gives me the result : 1 2 which is correct print_page(1,2) gives me the result : 2 3 which is wrong print_page(2,2) gives me the result : 3 4 which is wrong.. it includes the last data of previous query always.. i want it like : page0 : 1,2 page1 : 3,4 my print_page function is like : <?php print_page($num1, $num2) query = "......................ASC LIMIT ".$num1.",".$num2; . . ?> any ideas what should i do ? Quote Link to comment https://forums.phpfreaks.com/topic/198227-why-it-gives-me-wrong-results/ Share on other sites More sharing options...
Mchl Posted April 11, 2010 Share Posted April 11, 2010 That's how SQL LIMIT clause works. First number indicates on which ROW to start, second how many rows to retrieve. To have paging, you would need to: function print_page($num1, $num2) { query = "......................ASC LIMIT ".($num1 - 1) * $num2.",".$num2; ... } Quote Link to comment https://forums.phpfreaks.com/topic/198227-why-it-gives-me-wrong-results/#findComment-1040053 Share on other sites More sharing options...
Rommeo Posted April 11, 2010 Author Share Posted April 11, 2010 Thank you mchl Quote Link to comment https://forums.phpfreaks.com/topic/198227-why-it-gives-me-wrong-results/#findComment-1040064 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.