if (isset($_GET['pro_id'])){
$product_id = $_GET['pro_id']; $get_pro = "select * from products"; $run_pro = mysqli_query($con, $get_pro);
while ($row_pro = mysqli_fetch_array($run_pro)){
$pro_id = $row_pro['product_id'];
$pro_title = $row_pro['product_title'];
$pro_price = $row_pro['product_price'];
$pro_image = $row_pro['product_image'];
//$pro_desc = $row_pro['product_desc'];
echo "
<div id = 'single_product'>
<h3>$pro_title</h3>
<img src='admin_area/product_images/$pro_image' width='400' height='300' />
<p><b>Rs. $pro_price</b></p>
<a href='index.php' style='float:left;'>Go Back</a><br>
<a href='index.php?pro_id=$pro_id'><button style='float:right;'>Add to Cart</button></a>
</div>
";
}
}
?>
答案 0 :(得分:0)
您需要在SQL查询中指定要获取的产品。您正在使用的那个,$get_pro = "select * from products";
获取所有产品。您想将其更改为:
$get_pro = "select * from products WHERE product_id=".((int)$product_id);
因此它只选择一个产品,即$_GET['pro_id']
中传递的产品。