0

我想要做的是显示我目前在我的 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 的信息。

4

1 回答 1

0

你需要写if如下

if($info && $info==$framenumber){
...
}
于 2012-12-11T18:30:40.843 回答