Jump to content

sum the mysql returned value


funbinod

Recommended Posts

Well, that's one way to do it, but the query wouldn't work like that.

 

You have to loop through all the query results, adding on each iteration:

// Assuming PDO is being used for the database query$sum = 0;while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {    $sum += $row['value'];}echo $sum;
Link to comment
Share on other sites

Hello,

Pls, my root@localhost lost privileges. I might have mistakenly done that. Please help, i cant do anything in mysql right now. I cant CREATE, SELECT and all other privileges are gone. Pls help.

Thanks

you should post a new topic. dont ask any question on any other topic....

Link to comment
Share on other sites

Hello,

Pls, my root@localhost lost privileges. I might have mistakenly done that. Please help, i cant do anything in mysql right now. I cant CREATE, SELECT and all other privileges are gone. Pls help.

Thanks

 

you should post a new topic. dont ask any question on any other topic....

 

he did, prior to posting here

http://w3schools.invisionzone.com/index.php?showtopic=50420

 

@CUBEDWELLER.

Please respect other threads unless you have something relevant to contribute otherwise, maintain the conversation in the thread you started for your topic. If you did, you would see you've already been giving an answer.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...