Even though this approach is not advisable, you should always peform required data manipulation at the database level only (using MySQL in your case). Search for GROUP BY clause and use of SUM() function in MySQL. The query will look something like -
SELECT SCORE, SUM(SCORE) TOTAL FROM (SELECT ID, SCORE FROM MYTABLE) GROUP BY SCORE;
Anyway, for the JavaScript solution, check this link -
http://jsbin.com/efacem/1/[
^]