How to display mysql rows that contain certain data?
I have a table in mysql with a row called 'newrelease'. If the item is a new release my form posts it as 'yes' if no 'no'.
How would i display all items that contain the data 'yes'?
$query = "SELECT * FROM movielist ORDER BY newrelease DESC LIMI开发者_JAVA技巧T 4";
You could filter the data on the PHP side, but that would be a bad idea : it would mean load more data than you need, for nothing...
The best solution is to use a where
clause in your SQL query, which would then look like this :
SELECT *
FROM movielist
WHERE newrelease = 'yes'
ORDER BY newrelease DESC
LIMIT 4
Up to you to re-integrate this in your PHP code ;-)
And, as an example of page that could give you some additionnal informations : Where (SQL) on wikipedia.
...
$query = "SELECT * FROM movielist where newrelease = 'yes' ORDER BY newrelease DESC LIMIT 4";
精彩评论