Preforming Math Operations on Database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hpmasterp
Forum Newbie
Posts: 3
Joined: Fri Sep 09, 2005 10:43 pm

Preforming Math Operations on Database

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

most, if not all, databases support such functions internally during query, from what I've seen...
AGISB
Forum Contributor
Posts: 422
Joined: Fri Jul 09, 2004 1:23 am

Post 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
foobar
Forum Regular
Posts: 613
Joined: Wed Sep 28, 2005 10:08 am

Post by foobar »

Post Reply