What i am trying to do is display all the purchases i currently have in my Puchase table. I want it so it displays the purchase Items which it does, however, i am trying to make it look like this:
Purchase Item 1
Click for more info links to ?info=ID and shows the rest of the information
This is the code i currently have:
<?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>";
}
}
}
}
?>
EDIT:
The Problem i am currently having is that when i click on more info it displays all the information of all three items instead of only just one. I have LIMITED the SQL to only grabbing one product, however, it just repeats the product on the other purchase ID even tho its not the correct product.
My Current Output looks like this:
Purchase Item 1:
Information displayed
Purchase Item 2:
Information display even though i do not want it to be displayed i just want purchase item 1 information to be displayed.
You need to write
ifas below