Page 1 of 1

Preforming Math Operations on Database

Posted: Sat Oct 22, 2005 3:50 pm
by hpmasterp
First I have to say I'm very much a noob at php and mysql...so sorry if this question is really dumb.

I'm just messin' around and I'm trying to make a page that calculates my gpa. I have my my grade and number of hours per class in a data base. How can I preform operations on the values?

I'm really not sure how to set this up. I know I need to find the average of hours times grade. Is there anything thing like:

Code: Select all

average($row['grade'] * $row['hour'])
Also, if possible does anyone have a good links to tutorials of the kind of thing I'm trying to do.

Thanks.

Tim Brown

Posted: Sat Oct 22, 2005 4:33 pm
by feyd
most, if not all, databases support such functions internally during query, from what I've seen...

Posted: Sun Oct 23, 2005 5:43 am
by AGISB
Yes you definately can do some calcualtions within a query. You can even do some simple if else stuff. Just take a look into math functions of the mysql documentation

Posted: Sun Oct 23, 2005 6:37 am
by foobar