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.

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.