ecabrera Posted April 30, 2015 Share Posted April 30, 2015 I want to get my price to the nearest quarter for example if its 563 it will go to 550. I don't know what the next step should be. All my prices are whole numbers not decimals. $sql = "SELECT AVG(pay) from `data` WHERE `o_state`='$o_state' and `d_state`='$d_state' and `first` LIKE '$firstdate%'"; $run = mysqli_query($db,$sql); $rows = mysqli_fetch_assoc($run); echo $mean = $rows['AVG(pay)']; $mean = round($mean, 0); Quote Link to comment https://forums.phpfreaks.com/topic/295988-nearest-quarter/ Share on other sites More sharing options...
Solution Barand Posted April 30, 2015 Solution Share Posted April 30, 2015 to round x to the nearest multiple of y result = round(x/y) * y (eg round(563/25) * 25 = 575) If you want to round down as in your example, use floor() instead of round() 3 Quote Link to comment https://forums.phpfreaks.com/topic/295988-nearest-quarter/#findComment-1510454 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.