Jump to content

[SOLVED] Need help with SUM function


StanLytle

Recommended Posts

I'm trying to add the values of a column called 'Views" and output the result.  This is what I have, but it does not work.  What am I doing wrong?

 

$sql_query = "SELECT SUM(Views) AS TotalViews FROM Photos";

$result = mysql_query($sql_query);

$num = mysql_num_rows($result);

$TotalViews=number_format($num);

echo "$TotalViews";

 

Thanks,

Stan

 

Link to comment
https://forums.phpfreaks.com/topic/53193-solved-need-help-with-sum-function/
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.