Forum Moderators: coopster

Message Too Old, No Replies

summing individual rows in mysql

         

dsdc

4:19 pm on Feb 12, 2005 (gmt 0)

10+ Year Member



I have created a php scoresheet that allows graders to enter scores for different criteria. It uses a mysql database to store the information.

I want each row to total, and cannot figure out how to do that.

Since new people and new scores will be added to the list, the total row needs to total new people as well.

I'm pretty new to this, so don't assume I know syntax, etc.

Can anyone tell me how to do this?

Name Spelling Math Science Total
Joe 15 11 45
Mary 11 22 41
Sam 7 3 11

dsdc

4:24 pm on Feb 12, 2005 (gmt 0)

10+ Year Member



This is closer to the look. Imagine cells instead of underscores, and actual results under Total instead of whitespace.

Name_____Spelling____Math_______Science________Total
Joe________15_________11__________45 _________
Mary_______11_________22__________41__________
Sam_________7__________3__________11__________

hakre

4:30 pm on Feb 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



hi dsdc, do you have one database table or more than one for the data?

if it's one would be something like this:

SELECT Name, Spelling, Math, Science, Spelling + Math + Science AS Total FROM table

-hakre

Zipper

4:30 pm on Feb 12, 2005 (gmt 0)

10+ Year Member



are you looking for a SQL statement? also, would u mind posting the algorithm ur using right now