Re: Getting average down to 5

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ryan A wrote:

Hey,

Having a bit of a problem working out the logic to this one (its 5am
now...),

basically people vote on pics like hotornot.com, but here they vote on
a scale of 1-5 (one being something like what was hit by a bus at birth and
five being
the person you will never have a chance to have children with)  :-D

Anyway.....how do i get the averages down to a max of 5pts?
eg:
1.2 is ok
4.5 is ok
5.0 is ok
3.1 is ok
1.1 is ok
2.2 is ok
etc
97.3 is not ok
5.3 is not ok
etc


Thanks,
Ryan

i assume you're using mysql and each row has a value of 1 - 5.

SELECT AVG(rating) as rating FROM table WHERE id = $id

then that will give you numbers as such:
3.4242
4.1212
etc..

then use number_format()

number_format($row['rating'], 1, '.', '');

3.4
4.1






--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.338 / Virus Database: 267.10.6/69 - Release Date: 8/11/2005

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux