I would appreciate it if you could tell me what the problem is with the PHP query

Asked 2 years ago, Updated 2 years ago, 33 views

It is related to the barcode I asked you below, but it turns out that there is a problem in the php statement, so I am going to solve this first.

<?php

require_once 'connBarcode.php';

if(isset($_GET['barcode'])) {
 $key = $_GET['barcode'];
 $query = "SELECT * FROM food WHERE barcode='$barcode'";
 $result = mysqli_query($conn, $query);
 $response = array();
 while($row = mysqli_fetch_assoc($result)) {
      array_push($response,
      array(
         'barcode'=>$row['barcode'],
         'food_name'=>$row['food_name'],
         'company_name'=>$row['company_name'])
      );
   }
echo json_encode($response);
}

mysqli_close($conn);

?>

I wrote it like this, and I checked it out

It came out like this... But there is definitely one in DB.

I think there must be a problem with the query statement, but isn't it right to use the where statement like that? Where is the problem?

php sql

2022-09-20 20:48

0 Answers

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.