简体   繁体   English

如何从PHP中的数据库中获取附近的价值?

[英]How to get nearby value from Database in PHP?

I have a table in my database which is related to another table, there are 2 fields in database one is minprice and another is maxprice , these fields have floating value stored in database (eg. 23.47 Lac). 我的数据库中有一个表与另一个表相关,数据库中有2个字段,一个是minprice ,另一个是maxprice ,这些字段具有存储在数据库中的浮点值(例如23.47 Lac)。 Now i want nearby value from database on 1 field, I am using round($r->minprice); 现在我想从1字段的数据库中获取附近的值,我正在使用round($r->minprice); for this, but it's giving me the value between (1-100), But i want like this (Suppose a property have price 13.45 lac, then it could be show min 10 lac on display), What will be the condition for this. 为此,但是它给了我(1-100)之间的值,但是我想要这样(假设某个物业的价格为13.45紫胶,那么它可能会显示至少10紫胶),这的条件是什么。

Here are my code.... 这是我的代码。

$praa = round($r->minprice);
$prop->meta_desc = $best." ".$subCat[0]->cat_name." ".$in." ".$cities->name
                    ." ".$Location->locations.","." ".$r->title." ".$subCat[0]->cat_name
                    ." ".$under." ".$praa." " ."Lac";

You can try this: 您可以尝试以下方法:

$praa = (int) round($r->minprice, -1);

It'll round to the nearest 10th. 四舍五入到最接近的第十位。

Live demo here 现场演示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM