Php详细信息视图代码没有显示产品的详细信息.php页面niether错误



今天我为产品创建了一个 PHP 详细信息视图页面,但详细信息视图代码没有显示产品详细信息.php页面也没有错误。[1 id int(20(]primary AUTO_INCREMENT [2 product_cat int(20(][3 cat_id int(20(][4file varchar(100(latin1_swedish_ci
5 product_title文本latin1_swedish_ci
6 product_price int(10( 否 无
7 product_desc

<?php 
        if(!isset($_GET['pro_id'])){
            $id = $_GET['pro_id'];
  $get_pro = "select * from newproduct where pro_id='$id'";
  $run_pro = mysqli_query($con, $get_pro);
  while ($row_pro=mysqli_fetch_array($run_pro)){
      $pro_id = $row_pro['id'];
      $pro_title = $row_pro['product_title'];
      $pro_desc = $row_pro['product_desc'];
      $pro_price = $row_pro['product_price'];
      $pro_image = $row_pro['file'];

      echo "
      <div class='probox8'>
      <div class='item89'>
      <h3 style='text-align:center;'>$pro_title</h3>
        <img src='admin_area/uploads/$pro_image' width='400' height='500' />
        <p style='margin-top:10px; margin-left:5px;'><b>Price:  </b>  $pro_price <b> SAR</b></p>
        <div style='padding:5px;'>
        <a href='index.php?add_cart=$pro_id' style='float:right;'><button >Add to Cart</button></a>
     </div>
     </div>
    </div>";
       }
      }
    ?>

$get_pro = "从 id='$id'的新产品中选择 *";

数据库表中没有prod_id列

您向我们展示的代码不会初始化数据库连接 ($con(。

if(!isset($_GET['pro_id'](({

因此,如果您没有 $_GET['pro_id'] 的值,则在查询中使用它?

$get_pro ="从新产品中选择 *,其中 pro_id='$id'";

这容易受到 SQL 注入的影响

没有错误检查 - 您应该在每次 mysqli 调用后检查错误。

$pro_id = $row_pro['id'];

为什么?您可以这样做:

print "<a href='index.php?add_cart=$row_pro[pro_id]' style='float:right;'><button >Add to Cart</button></a>n"

最新更新