Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/232.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何查询选择两个变量之间的位置_Php_Mysql_Codeigniter - Fatal编程技术网

Php 如何查询选择两个变量之间的位置

Php 如何查询选择两个变量之间的位置,php,mysql,codeigniter,Php,Mysql,Codeigniter,我有这段代码来过滤产品价格,但我仍然对使用两个变量进行选择WHERE…BETWEEN查询感到困惑。这是代码: $min=$this->input->post('minValue'); $max=$this->input->post('maxValue'); $this->db->select('*'); $this->db->from('msproduct'); $this->db->where('ProductPrize BETWEE

我有这段代码来过滤产品价格,但我仍然对使用两个变量进行
选择WHERE…BETWEEN
查询感到困惑。这是代码:

$min=$this->input->post('minValue');
$max=$this->input->post('maxValue');
$this->db->select('*');
$this->db->from('msproduct');
$this->db->where('ProductPrize BETWEEN $min AND $max');
$query = $this->db->get();
data['product']=$query->result();
$this->load->view("user/product/product_filter",$data); 
我得到了这个错误:

“where子句”中的未知列“$min”


这可能是因为中未计算
$min
$max
变量

$this->db->where('ProductPrize BETWEEN $min AND $max');
换成

$this->db->where("ProductPrize BETWEEN $min AND $max");

请注意引用
不会在内部计算php变量,但
会对其进行计算这可能是因为
$min
$max
变量未在内部计算

$this->db->where('ProductPrize BETWEEN $min AND $max');
换成

$this->db->where("ProductPrize BETWEEN $min AND $max");
请注意引号。
不会计算内部的php变量,但
会计算它们的值。

您可以尝试以下方法:

$min=$this->input->post('minValue');
$max=$this->input->post('maxValue');
$this->db->select('*');
$this->db->from('msproduct');
$this->db->where('ProductPrize >=', $min);
$this->db->where('ProductPrize <=', $max);
$query = $this->db->get();
data['product']=$query->result();
$this->load->view("user/product/product_filter",$data);
$min=$this->input->post('minValue');
$max=$this->input->post('maxValue');
$this->db->select('*');
$this->db->from('msproduct');
$this->db->where('ProductPrize>=',$min);
$this->db->where('ProductPrize您可以尝试以下方法:

$min=$this->input->post('minValue');
$max=$this->input->post('maxValue');
$this->db->select('*');
$this->db->from('msproduct');
$this->db->where('ProductPrize >=', $min);
$this->db->where('ProductPrize <=', $max);
$query = $this->db->get();
data['product']=$query->result();
$this->load->view("user/product/product_filter",$data);
$min=$this->input->post('minValue');
$max=$this->input->post('maxValue');
$this->db->select('*');
$this->db->from('msproduct');
$this->db->where('ProductPrize>=',$min);
$this->db->where('ProductPrize try
$this->db->where(“ProductPrize介于$min和$max之间”);
try
$this->db->where(“ProductPrize介于$min和$max之间”);