Link to home
Start Free TrialLog in
Avatar of allanch08
allanch08Flag for United Kingdom of Great Britain and Northern Ireland

asked on

MYSQL decimal point

Hello experts.

I've come up with a simple 5-star rating system. Everything works fine but the calcualted answer is too long. ie. 2.4444 but I'd like it to be 2.44.

Do I be make this adjustment in MYSQL or PHP and how would i do it?

MYSQL statement:

SELECT ((1star+2star*2+3star*3+4star*4+5star*5)/(1star+2star+3star+4star+5star))
FROM rating
WHERE prod_id = colname

PHP to print answer is attached:

<?php echo $row_rsRating['((1star+2star*2+3star*3+4star*4+5star*5)/(1star+2star+3star+4star+5star))']; ?>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of hernst42
hernst42
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of allanch08

ASKER

thanks for quick reply, works a treat. as a matter of interest how would I do it in mysql?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thanks for help everyone