Jump to content

Sum of values in database help


mattm1712

Recommended Posts

Without any type of help regarding what it is you want to achieve it's pretty difficult but if your "id" field is set to AUTO_INCREMENT then it might not return anythign as AI starts counting at 1 and never 0.

 

If you want to return the total you can use this instead:

$total = mysql_query("SELECT COUNT(*) AS total FROM comments WHERE id=0");
$row=mysgl_fetch_assoc($total);
echo $row['total']." Clicks\n";

 

If you're not wanting the SUM() then try TOTAL() but not sure entire what it is you're wanting to do.

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.