简体   繁体   中英

Mysqli Query results returns empty but shouldn't

I run the query directly through PHP MyAdmin and it returns 1 result. Am I missing something? Well clearly I must be and I can't wrap my head round it!?!

I think I'm just tired or something! Any help would be much appreciated:-

$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'];

Closing ) and " issue it would be

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

Try that - you might have to print the results in loop.

$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"]);
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM