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); Link to comment https://forums.phpfreaks.com/topic/295988-nearest-quarter/ Share on other sites More sharing options...
Barand Posted April 30, 2015 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() Link to comment https://forums.phpfreaks.com/topic/295988-nearest-quarter/#findComment-1510454 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.