Jump to content

[SOLVED] php count / php sum


AsiaUnderworld

Recommended Posts

Hi, im trying to get php to sum the total of figures in a row in my database

 

the row is called msgtotal and table called user_stats , in the row msg total, theres one value 3, one of 1, then the rest are currently 0 , so the total should be 4, however it always says its 1

 

heres my code..

 

$sql2 = ("SELECT forumposts,msgtotal FROM user_stats");

$sql2 = mysql_query($sql2) or die(mysql_error());

$total_messages = mysql_fetch_assoc($sql2);

 

and then echo the following

 

<?=number_format(count($total_messages['msgtotal']))?>

Link to comment
https://forums.phpfreaks.com/topic/152112-solved-php-count-php-sum/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.