Jump to content

working with Decimals


alexguz79

Recommended Posts

Hey everybody...

 

i have this peace of code that gime me an average between total_hits and atBats (i'm working a baseball league website) but the thing echo all the numbers after the decimal dot... i just want tree... ex: is giving me 0.666666666667 and i could use better .666

 

anyone knows how to get me there?

 

here's the code:

 

<? $sql5="select total_hits from bateadores_locales WHERE profile_id ='$id' && year = '2010'"; 
$cons5=mysql_query($sql5); while($resultado5=mysql_fetch_array($cons5)) $suma5+=$resultado5['total_hits']; ?><? $sql6="select ab from bateadores_locales WHERE profile_id ='$id' && year = '2010'"; 
$cons6=mysql_query($sql6); while($resultado6=mysql_fetch_array($cons6)) $suma6+=$resultado6['ab']; echo (($suma5."") / ($suma6."")) ?>

 

 

thanks

Link to comment
https://forums.phpfreaks.com/topic/206109-working-with-decimals/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.