if you are talking about getting the average from a set of data in mysql, it provides a built in function avg to calculate averages from result sets.
here is an example:
SELECT avg(COLNAME) FROM table;
it will return the average of all the numeric data in COLNAME.
if you want to do it in php, basically you have to keep a counter of how many numbers you have added and once you finish the addition, divide by the number in the counter.