I am getting price values from mysql database table with the given php code
$sql="SELECT DISTINCT (price) FROM 'table' order by price asc";
$res=mysql_query($sql);
while($row=mysql_fetch_array($res))
{
$price=number_format($row[price]);
}
$price=implode(',',$price);
The result is 2,299,4,600,5,800,8,000,12,700,16,900,23,978,27,098
but i want to display the result as $2,500 or less,$5,000 or less,$7,500 or less,$10,000 or less,$15,00 or less,$20,000 or less,$25,000 or less,$30,000 or less
Can anyone tell me how o fix this problem
$price = '$' . number_format(ceil($row['price']/2500.0)*2500) . ' or less';
The ceil function takes a floating-point number and returns the next-highest integer. By dividing by 2500.0
and then multiplying again, we get the next-highest multiple of 2500.