funbinod Posted May 11, 2014 Share Posted May 11, 2014 i want to know how to sum the numbers returned from a php query of mysql data. please guide through... Link to comment Share on other sites More sharing options...
Ingolme Posted May 11, 2014 Share Posted May 11, 2014 Do you know how to sum a set of numbers in an array? Link to comment Share on other sites More sharing options...
funbinod Posted May 12, 2014 Author Share Posted May 12, 2014 is it like --> $array = array(1,2,3,4,5);$sum = array_sum($array);echo $sum; // 15 Link to comment Share on other sites More sharing options...
Ingolme Posted May 12, 2014 Share Posted May 12, 2014 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 More sharing options...
CUBEDWELLERS Posted May 18, 2014 Share Posted May 18, 2014 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 Link to comment Share on other sites More sharing options...
funbinod Posted May 20, 2014 Author Share Posted May 20, 2014 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 More sharing options...
thescientist Posted May 20, 2014 Share Posted May 20, 2014 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. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now