Reputation: 49
I am being stumped over this problem, and I can't seem to figure it out, hoping someone here can do make heads or tails over this.
When I use the following to query my database:
$q = "SELECT * FROM items WHERE (searchable='1' and title LIKE'%".$_srch."%')";
the items show up they way they are supposed to. But when I add limit 10, 5
to the end:
$q = "SELECT * FROM items WHERE (searchable='1' and title LIKE'%".$_srch."%') limit 10, 5";
The query shows up nothing. I have tried everything I can think of, but I must have missed something. Someone help?
Thanks
Upvotes: 4
Views: 239
Reputation: 3125
By using LIMIT 10, 5
you're stating that you want the database to start displaying from the 11th row, and display 5 rows. (11th, 12th, 13th, 14th, 15th) - It might be possible that you actually, don't have enough rows.
Try something like, LIMIT 0, 5
- this will display the first 5 rows from the beginning, but 10, 5 will only work if you have more than 10 rows for the search query.
Read more here: http://www.mysqltutorial.org/mysql-limit.aspx
Upvotes: 9
Reputation: 81
The Limit clause arguments are offset and number of items respectively. So the query you write would show 5 rows starting from the 10th row.
How many rows does your original query show. If it is less then 10 rows then the limit query you provide wont work as the number of rows are less.
Upvotes: 0