I want to add to my load more posts query below the following line
OR p.posted_to='$userid'
but when i add in the OR statement, to the query below, it returns results, but it just keeps repeating the same posts, every time i click load more, instead of loading older posts.
if i add this OR statement to my regular show posts, it does what it is supposed to do. the only issue arises when i am adding the OR statement to the loadmore posts query below.
$sql = "SELECT p.body, p.user_id, p.posted_to, p.post_likes,p.stamp, p.id,u.username, u.imagelocation
FROM posts p
INNER JOIN users u
ON p.user_id=u.id
WHERE p.user_id='$userid'
AND p.id <'$lastcomment'
ORDER BY p.stamp DESC
LIMIT 0,3";
I assume you wrote something like this:
This doesn’t work because AND has higher precedence than OR. You need parentheses.
Without the parentheses it will be interpreted as follows: