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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.