Page 1 of 1

Adding multiple mysql row records

Posted: Thu Feb 03, 2011 1:51 pm
by tomsace
Hi,
I have a database set out like this:

User - # of times played
User1 - 13
User2 - 21
User3 - 92 etc...


I would like to know how to add all the # of times played together?
Thanks in advanced.

Re: Adding multiple mysql row records

Posted: Thu Feb 03, 2011 2:12 pm
by anantha
when you use mysql to get the content..i assume the db is mysql....you will get an array...use array_count_values($array)...u will get the sum

Re: Adding multiple mysql row records

Posted: Thu Feb 03, 2011 2:54 pm
by John Cartwright

Code: Select all

SELECT SUM(`your_count_column`) AS `times_played` FROM `your_count_table`

Re: Adding multiple mysql row records

Posted: Sat Feb 05, 2011 4:11 pm
by tomsace
Got it working beautifully, thanks alot :)