almystersv Posted January 10, 2008 Share Posted January 10, 2008 Hi Guys, I want my page to display all the previous orders made and the relevant details. It does do this at the moment but it repeats the order number with every product it shows. Ideally I want to have the order number just once, then all the products related to that order listed below. Would also like the price of all the products to be added up into a total but havent looked into that yet. Help with either would be great Here is my past orders page... <?php session_start(); if (isset($_SESSION['username']) == false){ header("Location: login.php"); exit(); } require "connect.php"; ?> <!DOCTYPE HTML PUBLIC "//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>BIS Portal</title> </head> <body> <?php include ("header.php"); ?> <h4> <table width="100%" border="1"> <tr> <th width="8%">Order Number</th> <th width="30%">Products</th> <th width="10%">Price</th> <th width="14%">Date</th> <th width="13%">User</th> <th width="30%">Status</th> </tr> <?php $query = "SELECT * FROM orders o, productorder e, product p, employee y WHERE o.orderID = e.orderID AND p.URN = e.URN AND y.empID = o.empID"; $result = mysql_query ($query, $connection) or die ("Unable to perform query<br>$query"); while($row = mysql_fetch_array($result)) { ?> <tr> <td><?php echo $row['orderID']?></td> <td><?php echo $row['productName']?></td> <td><?php echo $row['price']?></td> <td><?php echo $row['date']?></td> <td><?php echo $row['fName']?><?php echo $row['sName']?></td> <td><?php echo $row['status']?></td> </tr> <?php } ?> </table> </h4> </body> </html> Quote Link to comment Share on other sites More sharing options...
interpim Posted January 10, 2008 Share Posted January 10, 2008 put an if statement to check if the order number exists in your output already, if so, then echo out a blank table cell. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted January 10, 2008 Share Posted January 10, 2008 You can use GROUP in the query to group it by the order number. That would be the first query. And when you query that and fetch the array, you can then make another query to loop through the database again and get the other results. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.