我想要做的是显示我目前在我的Puchase表中购买的所有商品。我想要它所以它显示它所做的购买物品,但是,我试图让它看起来像这样:
购买物品1
单击以获取更多信息链接?info = ID并显示其余信息
这是我目前的代码:
<?php
$sql="SELECT PurchaseID, FrameNumber, Date From Purchase WHERE Email = '$id'";
$purchases = mysqli_query($con, $sql);
while(list($purchaseid, $framenumber, $date) = mysqli_fetch_row($purchases)){
echo "
<table width=\"100%\">
<tr>
<th>PurchaseID:</th>
<th>Date Of Purchase:</th>
<th>FrameNumber:</th>
<th>More Details</th>
</tr>
<tr>
<td>$purchaseid</td>
<td>$date</td>
<td>$framenumber</td>
<td><a href=\"myaccount.php?info=$framenumber\">Click Here</a></td>
</tr>
</table>";
$info = $_GET['info'];
if($info){
$fnumber = mysqli_query($con, "SELECT BikeCode FROM BikeStock WHERE FrameNumber = '$info'");
while(list($bikecodes) = mysqli_fetch_row($fnumber)){
$bikes = mysqli_query($con, "SELECT * From Bike WHERE BikeCode = '$bikecodes' LIMIT 1");
while(list($bikecode, $manufacturer, $model, $subtype, $year, $fmaterial, $desc, $gender, $type, $price, $stock) = mysqli_fetch_row($bikes)) {
echo "<table><tr><th>BikeCode:</th>
<th>Manufacturer:</th>
<th>Model:</th>
<th>FrameMaterial:</th>
<th>Year:</th>
</tr>
<tr>
<td>$bikecode</td>
<td>$manufacturer</td>
<td>$model</td>
<td>$fmaterial</td>
<td>$year</td>
</tr>
<tr><th>Description:</th><td colspan=\"4\">$desc</td></tr>
<tr><th>Bike Images:</th><td colspan=\"4\">
<div id=\"gallery\">";
$sql = "SELECT SourcePath, Description FROM BikeImages where bikecode = '$bikecode'";
$result = mysqli_query($con, $sql) or die('Query2 failed: ' . mysqli_error($con));
while(list($sourcepath, $description) = mysqli_fetch_row($result)) {
echo "<a class=\"gallery\" href=\"$sourcepath\" title=\"$description\"><img src=\"$sourcepath\" width=\"72\" height=\"72\" /></a>";
}
echo "</div></td></tr></table>";
}
}
}
}
?>
编辑: 我目前遇到的问题是,当我点击更多信息时,它会显示所有三个项目的所有信息,而不仅仅是一个。我将SQL限制为只抓取一个产品,但是,它只是在其他购买ID上重复产品,即使它不是正确的产品。
我的当前输出如下:
购买物品1:
显示的信息
购买第2项:
即使我不希望显示信息显示,我只想显示购买项目1信息。
答案 0 :(得分:0)
您需要编写if
,如下所示
if($info && $info==$framenumber){
...
}