Tuesday, 17 September 2013

MYSQL show only the last 8 rows

MYSQL show only the last 8 rows

On my index page i have the "latest work" which shows 8 portfolio pieces
and i need it to only grab the ones that have active = 1 as well and i
have something like this:
$sql = 'SELECT * FROM portfolio WHERE active = 1';
I tried doing this but its not working and i get errors when i try to pass
it in phpmyadmin as well.
$sql = 'SELECT * FROM portfolio
WHERE active = 1
WHERE [id] > SELECT
MAX([id]) - 8 FROM portfolio';
Any ideas?

No comments:

Post a Comment