Re: printing average out of an integer

From: Date: Mon, 20 Mar 2000 21:53:22 +0000
Subject: Re: printing average out of an integer
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-17103@lists.php.net to get a copy of this message
Edsard Ravelli writes: > Hello developers, > > Who knows the function to print the average of the perticular table to > the browser. > > Example in a the tabel "marques" there are a 5 , 3 and a 4, the average > of that is 4. > What function is there for such a query? > > Thanks in advance. > > Edsard Ravelli > PLANET MEDIA GROUP > http://www.planet.nl > > ps. know any good links for stuff like this. I already have the core php > programming book and some links, but allot is never enough. If it's in a database table, you should check whether the database offers an avg() grouping function or some such. Doing this in the db instead of in PHP will likely end up being more efficient. From the MySQL manual: AVG(expr) Returns the average value of expr. mysql> select student_name, AVG(test_score) from student GROUP BY student_name; Otherwise, just add 'em all together and divide by the number of numbers you have and there you go. -- +----------------------------------------------------------------+ |Torben Wilson <torben@php.net> Netmill iTech| |http://www.coastnet.com/~torben http://www.netmill.fi| |Ph: 1 250 383-9735 torben@netmill.fi| +----------------------------------------------------------------+

« previous php.dev (#17103) next »