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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.