The following is the feature stripped version of a script I'm working on. It's simple to pick up on the idea, but what it should do is print out the correct article maching the id number if one is present on the url. That part works fine.
The else statement should cause the script to print out the latest article if no id is present on the url. This is done by doing a SELECT COUNT(*), then using that number as the basis for the $result select. For whatever reason though the $total_rows variable is being set to 2, when in fact it should be 18. Where is this messed up?
if ($id) {
$result = mysql_query("SELECT * FROM journal WHERE id=$id",$db);
$myrow = mysql_fetch_array($result);
printf("%s<br>", $myrow["title"]);
printf("%s<br><br>", $myrow["posted"]);
printf("%s<br><br>", $myrow["playing"]);
printf("%s<br>", $myrow["journal"]);
} else {
$total_rows = mysql_query("SELECT COUNT() FROM journal",$db);
$result = mysql_query("SELECT FROM journal WHERE id=$total_rows",$db);
$myrow = mysql_fetch_array($result);
printf("%s<br>", $myrow["title"]);
printf("%s<br><br>", $myrow["posted"]);
printf("%s<br><br>", $myrow["playing"]);
printf("%s<br><br>", $myrow["journal"]);
}