I am trying create a order history page. An SQL statement that finds all the applications based on a order_ID in an orderdetails_tbl. Here is the SQL.
SELECT * FROM applications_tbl INNER JOIN orderdetails_tbl ON orderdetails_tbl.app_ID = applications_tbl.app_ID WHERE orderdetails_tbl.order_ID = $orderID
The results are displayed using this PHP.
$result = mysql_query("SELECT *
FROM applications_tbl
INNER JOIN orderdetails_tbl ON orderdetails_tbl.app_ID = applications_tbl.app_ID WHERE orderdetails_tbl.order_ID = ".$order_ID."");
$row = mysql_fetch_assoc($result);
echo "<table>";
do { ?>
<tr style="background-color:#fff">
<td> <img src="getimage.php?ID=<?php echo $row['app_ID']; ?>" width="100" height="100" alt="IMAGE" /></td>
<td width="20%"><?php echo $row['app_name']; ?></td>
<td><?php echo $row['app_desc']; ?></td>
<td width="15%"><?php echo $row['app_cost']; ?></td>
</tr>
<?php
} while ($row = mysql_fetch_assoc($result));
The SQL returns the correct values and the PHP displays them correctly. My issue is that it on the webpage it returns many duplicate results. It appears to be random, but I noticed the more apps/items in the order the more duplicate results. In phpMyAdmin when I run the SQL it doesn't display duplicates.
Cheers for your time. Any advice will be greatly received!
mysql_fetch_roworderdetails_tblsounds like it holds the line items of the order. You should have anotherordertable for the head of the order. Otherwise, you could just useSELECT DISTINCT.SELECT *on the table. Specify the fields you need and then also add a DISTINCT statement