php+mysql,如何使post的变量为空时where查询中不做该变量的判断?
//这里是PHP代码$department=$_POST['department'];$state=$_POST['state'];$date=$_POST['date'...
//这里是PHP代码
$department = $_POST['department'];
$state = $_POST['state'];
$date = $_POST['date'];
$class = $_POST['class'];
$bus = $_POST['bus'];
$sql = "SELECT * FROM `addr_list`
WHERE `department`='$department' and
`state`='$state' and
`date`='$date' and
`class`='$class' and
`bus`='$bus' ";
网页上做一个数据表的条件筛选,当post的五个变量都有值时,才能筛选成功。如何使post的变量为空时where查询中不做该变量的判断。 展开
$department = $_POST['department'];
$state = $_POST['state'];
$date = $_POST['date'];
$class = $_POST['class'];
$bus = $_POST['bus'];
$sql = "SELECT * FROM `addr_list`
WHERE `department`='$department' and
`state`='$state' and
`date`='$date' and
`class`='$class' and
`bus`='$bus' ";
网页上做一个数据表的条件筛选,当post的五个变量都有值时,才能筛选成功。如何使post的变量为空时where查询中不做该变量的判断。 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询