您好我从数据库中获取数据,但这只显示ID号。仅当我点击其他项目时才有1个数据。这是id no的链接。 2但显示id为1的数据。
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";
}
?>
这是我用来从数据库中获取数据的代码。我是编程人员的新手,所以请帮帮我
答案 0 :(得分:1)
$id = isset($_GET['id']);
=&gt; $ id设置为1
更改
$id = isset($_GET['id']);
要
$id = isset($_GET['id']) ? $_GET['id'] : 0;