Jump to content

Help with Mysqli and Limits


runnerjp
 Share

Recommended Posts

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Are you sure you have something important to add to it?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.