public function fetch_price_range_ads($min,$max)
{
$this->db->select('*');
$this->db->from('user_added_ads');
$this->db->join('media_ads','media_ads.user_added_ads_id=user_added_ads.user_added_ads_id');
$this->db->group_by('user_added_ads.user_added_ads_id');
$this->db->where('user_added_ads.price >= ',$min);
$this->db->where('user_added_ads.price <=', $max);
$q=$this->db->get();
return $q->result();
}
这是我的模型页面,一切正常,但事情是如果$ min = 1200和$ max = 1500,它获取价格范围从1200和1500开始的所有数据, Ex apple = 12010;
答案 0 :(得分:0)
尝试以下方法:
$this->db->where("user_added_ads.price BETWEEN $min AND $max");
答案 1 :(得分:0)
我尝试了,但它也没用,无论如何谢谢,我得到了答案,
in controller
$min=$_POST['minimum'];
$max=$_POST['maximum'];
$mins = ( int ) str_replace( ',', '', $min );
$maxs = ( int ) str_replace( ',', '', $max );
$data['price_range']=$this->mymodel->fetch_price_range_ads($mins,$maxs);
这将起作用