Jump to content

[SOLVED] Grouping results by order Number


almystersv

Recommended Posts

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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.