PDA

View Full Version : variable with sql count results


a4toronto
05-20-2002, 08:15 PM
i have the following line of code:
$user=$DB_site->query("SELECT COUNT(*) FROM post WHERE userid='$userid' AND review=1");

how do i get access to the count results?

echo $user displays "resource id#12"

a4toronto
05-20-2002, 08:31 PM
just to clarify, the goal of my code is to update the contents of a field with the number of rows that have the "review" flag set to 1.

Logician
05-21-2002, 08:49 AM
$user=$DB_site->query("SELECT COUNT(*) as posts FROM post WHERE userid='$userid' AND review=1");

echo number_format($user['posts']);

Admin
05-21-2002, 08:55 AM
You also need to use $DB_site->query_first() instead of query().