runnerjp Posted November 10, 2014 Share Posted November 10, 2014 Hi, Im using Mysqli and im trying to limit the results by 10 and order them from last to first from the database. $sqlhorses = "SELECT Place FROM `*` WHERE `Horse` ='".$db->real_escape_string($row['horse']). "'"; the above works but when i added the limit 6 to the end it shows errors. Can anyone help? Quote Link to comment https://forums.phpfreaks.com/topic/292392-help-with-mysqli-and-limits/ Share on other sites More sharing options...
Barand Posted November 10, 2014 Share Posted November 10, 2014 the above works ??? Quote Link to comment https://forums.phpfreaks.com/topic/292392-help-with-mysqli-and-limits/#findComment-1496244 Share on other sites More sharing options...
QuickOldCar Posted November 10, 2014 Share Posted November 10, 2014 Did you mess up the positions of that wildcard? * I would hope the data already in your database is safe. $sqlhorses = "SELECT * FROM Place WHERE `Horse` ='".$row['horse']. "' GROUP BY id DESC LIMIT 10"; Sounds like you need pagination, there is an old tutorial here at phpfreaks can follow, but should make it mysqli or pdo http://www.phpfreaks.com/tutorial/basic-pagination with pagination would also include the startrow GROUP BY id DESC LIMIT 0,10 GROUP BY id DESC LIMIT 9,10 GROUP BY id DESC LIMIT 19,10 Quote Link to comment https://forums.phpfreaks.com/topic/292392-help-with-mysqli-and-limits/#findComment-1496246 Share on other sites More sharing options...
Barand Posted November 10, 2014 Share Posted November 10, 2014 Why the "GROUP BY id"? Don't you mean "ORDER BY id"? Do you want to try recalculating those start record numbers? first 10: 0 - 9 next 10: 10 - 19 next 10: 20 - 29 Quote Link to comment https://forums.phpfreaks.com/topic/292392-help-with-mysqli-and-limits/#findComment-1496248 Share on other sites More sharing options...
QuickOldCar Posted November 10, 2014 Share Posted November 10, 2014 Was a late night, you are right. Quote Link to comment https://forums.phpfreaks.com/topic/292392-help-with-mysqli-and-limits/#findComment-1496268 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.