Forum Moderators: coopster
<?
// reset guests, registered and total
$total = 0;
// db connection
$hostname = "";
$username = "";
$password = "";
$dbname = "";
// connect to database
$connection = mysql_connect($hostname,$username,$password) or die ("Cannot connect to server.");
$db = mysql_select_db($dbname,$connection) or die ("Could not select database.");
// count total cars in database
$sql = "SELECT COUNT(id) AS cars FROM phpbb_garage WHERE id>0";
$total = mysql_result(mysql_query($sql, $connection), 0,"cars");
// close the db-connection
mysql_close($connection);
// generate the output
$output="total:" . $total . "";
// print the output
echo "$output";
?>
if i use this script for the item i cant get working, it returns the incorrect value. i figured out that it is totaling all the rows that meet the criteria, not totalling the values of the rows that meet the criteria. any help is appreciated. i barely squeezed by with the script above. ;-)
im trying to count the total of new private messages a user has. some users have more than 1 so a simple COUNT(new_private_messages) WHERE new_private_messages>0 wont work. thanks for any help.
our local sysadmin at work didnt think of it first when i asked for his guidance in the general direction
Many sysadmins aren't adept at writing SQL, so you can't hold that against the chap. Note, I said many, not all -- so any future readers that are both do not take offense to this message and know that my hat is off to you ;)