如何在PHP的while循环中使用AND运算符的三个条件

如何在PHP的while循环中使用AND运算符的三个条件,php,mysql,Php,Mysql,如何在PHP的while循环中使用AND运算符的三个条件 这是我的密码: $query = "select * from agent_profile where status = 1"; $run = mysqli_query($con, $query); $pricequery = "select * from airport_parking where airport_name = '$airport' AND '$parking_start_time' >= start_time

如何在PHP的while循环中使用AND运算符的三个条件 这是我的密码:

$query = "select * from agent_profile where status = 1";
$run = mysqli_query($con, $query);

$pricequery = "select * from airport_parking where airport_name = '$airport' AND '$parking_start_time' >= start_time ";
$resultprice = mysqli_query($con, $pricequery);

$squery = "select * from agent_services where agent_id = '$crnt_id' AND service_type = '$service_type' ";
$srun = mysqli_query($con, $squery);


if ($run && $resultprice && $squery) {
    while (($datarow = mysqli_fetch_array($run)) AND ($getdata = mysqli_fetch_array($resultprice)) AND ($sdata = mysqli_fetch_array($srun))) {
    }
试试这个

$query = "select * from agent_profile where status=1
        UNION
        select * from airport_parking where airport_name = '$airport' AND  '$parking_start_time' >= start_time 
        UNION
        select * from agent_services where agent_id = '$crnt_id' AND service_type='$service_type';";
$run = mysqli_query($con,$query);

if(strlen($run) <> ''){

    while (($datarow = mysqli_fetch_array($run)))
   {
       $column_name = $datarow['column_name'];
   }
}

并将保持while,直到所有条件都为true为止,也就是说,它将一直运行,直到所有选择的所有fetch记录上都有相同数量的记录为止。在这种情况下,您可能需要使用或条件。建议对每个变量使用array_map或1 while。您需要将这3个SQL查询合并为一个查询,或者单独获取所有查询并在PHP中合并它们,这将浪费资源。查看UNION或如何加入SQL查询我建议您分别对每个查询执行while循环,但我希望进行筛选这就是为什么我希望使用while循环并筛选数据感谢您的回复,但它不会返回任何结果。我的意思是,它显示没有数据,但我在数据库中有与search@Rayn:请现在检查。您现在能告诉我,如何从数据库中保存while条件中变量的值吗?@Rayn:请现在检查。即使语句为true,它仍然返回else语句