Mysqli查询结果返回空,但不应该返回

时间:2015-11-19 11:06:30

标签: php mysqli

我直接通过PHP MyAdmin运行查询,它返回1个结果。我错过了什么吗?很清楚,我一定是这样,我不能把它包裹起来!?!

我想我只是厌倦了什么! 任何帮助将不胜感激: -

$query_road_tax = mysqli_query($conn011, "SELECT * FROM road_tax_pricing WHERE (tax_from_co2 <='$vehicle_co2' AND tax_upto_co2 >='$vehicle_co2'");
$row_road_tax = mysqli_fetch_assoc($query_road_tax);
$Six_Month=$row_road_tax['tax_6month'];
$Twelve_Month=$row_road_tax['tax_12month'];

2 个答案:

答案 0 :(得分:4)

关闭) and "问题将是

$query_road_tax = mysqli_query($conn011, "SELECT * FROM 
road_tax_pricing WHERE (tax_from_co2 <='$vehicle_co2' AND tax_upto_co2 >='$vehicle_co2')");

答案 1 :(得分:1)

试试 - 你可能需要循环打印结果。

$query = "SELECT * FROM road_tax_pricing WHERE (tax_from_co2 <='$vehicle_co2' AND tax_upto_co2 >='$vehicle_co2')";

if($query_road_tax = mysqli_query($conn011, $query)) {
  while ($row = mysqli_fetch_assoc($query_road_tax)) {

      /* print_r($row); */

      printf($row["tax_6month"]);
      printf($row["tax_12month"]);
  }
}