SELECT * FROM posts ORDER BY `posts`.`postid` DESC WHERE postid < ".$_POST['last_video_id']." LIMIT 8 ;
Asked
Active
Viewed 31 times
-4
-
Well your order by is in the wrong place and you have SQL injection problem... what is the error exactly? – Alex Barker Oct 27 '20 at 18:02
-
You should place the WHERE before the ORDER BY – Burhan Kashour Oct 27 '20 at 18:02
1 Answers
1
You have to put the conditions in your query in the correct order
SELECT *
FROM posts
WHERE postid < ?
ORDER BY postid DESC
LIMIT 8
And you should use prepared statements that savely fill the parameters in your query.

juergen d
- 201,996
- 37
- 293
- 362