Jump to content

[SOLVED] SUM function help


kevincro

Recommended Posts

I'm trying to return the sum of a field in a mysql database using PHP.  For some reason the function doesn't want to return a value.  It gives me a result resource message.  The following is the code that I'm using.

 

$query5 = "SELECT SUM(num) FROM bappurchased WHERE bapnumber='$data_key'";
$result5=mysql_query($query5);

 

$data_key is a variable that is carried over from a previous page and it holds a numerical value that corresponds to the rows that contain the field that I'm trying to sum. I'm trying to return the sum of these fields and use the value for further calculations on the same page.

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