简体   繁体   English

从数据库中仅获取单个ID的数据

[英]Getting only single id's data from database

Hi i am fetching data from data base but this is showing only id no. 嗨,我正在从数据库中获取数据,但这仅显示ID号。 1 data only when i click on other items.This is the link of id no. 仅当我单击其他项目时才有1个数据。这是ID号的链接。 2 but showing the data of id no 1. 2,但显示ID为1的数据。

http://localhost/ecom/details.php?item_title=Sample2&id=2 http://localhost/ecom/details.php?item_title = Sample2&id = 2

 if (isset($_GET['id'])) {

                          $id = isset($_GET['id']);

                           $sql = "SELECT * FROM men_watches WHERE id = '$id' ";

                           $run = mysqli_query($conn, $sql);
                                if (false === $run) {
                                        echo mysql_error();
                                    }  

                           while($row = mysqli_fetch_array($run)) {
                          $discounted_price = $row['item_price'] - $row['item_discount'];

                      echo "
                           <div class='col-md-6'>
                           <h3 class='pp-title'>$row[item_title]</h3>
                           <img src='$row[item_image]' class='img-responsive' >
                           <div class='bottom'>

                           <div class='pull-right cutted-price text-muted'><del>$ $row[item_price]</del></div>
                           <div class='clearfix'></div>
                           <div class='pull-right disscounted-price'>$$discounted_price</div>
                           </div>
                           <h4 class='pp-dsc-title'>Description</h4>
                           <div class='pp-dsc-detail'>$row[item_description]</div>
                           </div> 

                   ";
                  }
               }else {
                    echo "The request is not working";
                }    
            ?>      

This is the code i am using to fetch the data from database.I am new in programming guys so please help me 这是我用来从数据库中获取数据的代码。我是编程人员中的新手,请帮助我

$id = isset($_GET['id']); => $id setting to 1 => $ id设置为1

Change 更改

$id = isset($_GET['id']);

To

$id = isset($_GET['id']) ? $_GET['id'] : 0;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM