Undefined variable
The error is in the get query but i do not know how to fix it. it have something with the $_id can anyone help me ?
1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <meta http-equiv="X-UA-Compatible" content="IE=edge"> 6 <meta name="viewport" content="width=device-width, initial-scale=1.0"> 7 <title>Details</title> 8 <style> 9 *{margin: 0;padding: 13px;box-sizing:border-box;} 10 .container{display: flex;} 11 </style> 12 </head> 13 <body> 14 <?php 15 require_once( "./config/db.php"); 16 if(isset($_GET['pr_id'])){ 17 $id = $_GET['pr_id'];} 18 19 $sql = "SELECT * FROM product WHERE pr_id= ". $id ; 20 $result = mysqli_query( $connect, $sql); 21 if ($result) 22 { 23 while ($row = mysqli_fetch_assoc($result)) 24 {?> 25 <div class="container"> 26 <div class="pr-left"> 27 <img src="./image/<?php echo $row['image'] ?>"> 28 </div> 29 <div class="pr-right"> 30 <h1><?php echo $row['pr_name'] ?></h1> 31 <h3>Price: <?php echo $row['price'] ?>VND</h3> 32 <button>BUY NOW</button> 33 <p>GIAO HÀNG TOÀN QUỐC <br> THANH TOÁN KHI NHẬN HÀNG <br> ĐỔI HÀNG TRONG 15 NGÀY</p> 34 </div> 35 </div> 36 <?php 37 } 38 } 39 else{echo 'loi';} 40 ?> 41 </body> 42 </html>
if(isset($_GET['pr_id'])){ $id = $_GET['pr_id']; // $id only exists within the scope of this block } // $id no longer exists here $sql = "SELECT * FROM product WHERE pr_id= ". $id ;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)