Here is my current MySQL syntax (but this doesn't work):
SELECT * FROM posts WHERE userID = $userID AND postBy = $postBy AND po开发者_StackOverflow中文版stType = 'unread'
Here is the picture of my MySQL table (a picture can show more than words!)
I want to know if there is any other way of doing it or if I have to forget this idea?
There's nothing wrong with what you're attempting to do, it's just that you haven't quoted the PHP variable
Make sure you're escaping/sanitizing your input. Also use prepared statements if possible
SELECT * FROM posts WHERE userID = $userID AND postBy = '{$postBy}' AND postType = 'unread'
You should really use parameters, but other than that you will need to enclose the text variables in single quotes.
SELECT * FROM posts WHERE userID = $userID AND postBy = '$postBy' AND postType = 'unread'
精彩评论