我尝试制作链接,当我点击该链接时,我想在新页面 (details.php
) 中从数据库中获取一些数据,但是当我尝试这样做时 ( details.php
) 页面打开时空无一物!!
链接代码为:
<a href='details.php?pro_id=$pro_id' sytle='float:left;'>Details</a>
在details.php页面的php代码是:
<?php
if(isset($_Get['pro_id'])){
$Product_id= $_Get['pro_id'];
$get_pro= "select * from products where Product_id = '$Product_id'";
$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='400px' height='300px' />
<p><b> Price $pro_price RO</b></p>
<a href='index.php?pro_id=$pro_id' sytle='float:left;'>Go Back</a>
<a href='index.php?pro_id=$pro_id'><button style='float:right';>Add to Cart</button></a>
</div>
";
}
}
?>
我找不到我的错误在哪里
最佳答案
变量在 PHP 中区分大小写,get 数组的正确名称是 $_GET
所以像这样修改你的代码
if(isset($_GET['pro_id'])){
关于php - 我无法从 php 中的链接中找到数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34841748/