Reputation: 2268
I am trying to display MySQL database selected records in descending order based on the last id. but it's not working please see the SQL statement below
SELECT * FROM product WHERE catagory='$pro' AND id >($id) LIMIT 6 DESC
I want to show only 6 records at a time.
Upvotes: 0
Views: 36
Reputation: 133360
add an order by eg:
SELECT * FROM
product WHERE catagory='$pro' AND id >($id)
ORDER BY id DESC LIMIT 6
but you should not use php var in sql you are at risk for sql injection
take a look at your sql driver for use binding param
Upvotes: 1
Reputation: 326
SELECT
*
FROM
product
WHERE
catagory = '$pro'
AND id > ($id)
ORDER BY id desc
LIMIT 6;
Upvotes: 0