使用php显示不同格式的mysql结果[关闭]

使用php显示不同格式的mysql结果[关闭]

问题描述:

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

我从mysql数据库表中获取给定php代码的价格值 p>

  $ sql =“SELECT DISTINCT(price)FROM'table'order by price asc”; 
 $ res = mysql_query($ sql); 
while($ row = mysql_fetch_array($ res))
 {\  n $ price = number_format($ row [price]); 
} 
 $ price = implode(',',$ price); 
  code>  pre> 
 
 

结果 是 2,299,4,600,5,800,8,000,12,700,16,900,23,978,27,098 code> p>

但我希望将结果显示为 $ 2,500或更少 ,$ 5,000或以下,$ 7,500或以下,$ 10,000或以下,$ 15,00或以下,$ 20,000或以下,$ 25,000或以下,$ 30,000或以下 code> p>

任何人都可以告诉我如何 o解决此问题 p> div>

$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.