I'm trying to retrieve the four most recent postings to a database. My basic query (without using "LIMIT" works, but if I try to restrict my results using LIMIT I get an error.
This works:
$result = mysql_query("SELECT cpdonors.first, cpdonors.last FROM cpdonors left join cpdonations ON cpdonors.id = cpdonations.donorid WHERE cpdonations.publish='name' ORDER BY cpdonations.date DESC");
while ($myrow = mysql_fetch_array($result)) {
echo $myrow['first'] . " " . $myrow['last'] . "<br>";
}
And this doesn't (I get a "not a valid result resource" error):
$result = mysql_query("SELECT cpdonors.first, cpdonors.last FROM cpdonors left join cpdonations ON cpdonors.id = cpdonations.donorid WHERE cpdonations.publish='name' ORDER BY cpdonations.date DESC LIMIT(0,4)");
while ($myrow = mysql_fetch_array($result)) {
echo $myrow['first'] . " " . $myrow['last'] . "<br>";
}
Of course maybe I'd just be better off doing a for loop on the whole result with $i <= 4... suggestions?