当我只输入最小值时,它会将最大值视为零,并返回空数据


when i enter only min value then it consider max as zero and return me null data

当我只输入最小值时,它将最大值视为零,并返回空数据

$min=$_REQUEST['min'];     
$max=$_REQUEST['max'];     
$q3="select * from product where '$min' < `price` < '$max'";    
$q=mysql_query($q3);

按最大值更改查询:

$min=$_REQUEST['min'];
$max=$_REQUEST['max'];
if( empty($max) )
   $q3="select * from product where price > '$min'";
else
   $q3="select * from product where price > '$min' and price < '$max' ";

$q=mysql_query($q3);

还有一个修正,你应该开始使用PDO。您使用的方法已折旧。

读取此

如果您没有在请求中提供值,php会将其视为NULL。你应该每次都提供价值,否则你可以做到这一点。

$min=$_REQUEST['min'];
$max=$_REQUEST['max'];
if(!$max){
   $max = 45; // or what ever value you like
}
$q3="select * from product where price > '$min' and price < '$max' ";
$q=mysql_query($q3);