You mean you had me writing PHP code for 30 minutes when I don't even *USE* PHP???
AAARRRGGGGHHHH!!
Well...FWIW, and remembering I don't use PHP, here's what I came up with:
Code:
<html>
<body>
<?php
... make your DB connection here ...
$orderid = (int)$_GET["order"]; // ensure that orderid *IS* an integer! no SQL injection
$sql = "SELECT customers.CompanyName,
orders.CustomerID, orders.OrderID, orders.Freight
order_details.Quantity,
products.ProductID, products.ProductName, products.UnitPrice,
shippers.CompanyName AS shipCompany
FROM customers, orders, order_details, products, shippers
WHERE customers.CustomerID = orders.CustomerID
AND orders.OrderID = " . $orderid . "
AND orders.OrderID = order_details.OrderID
AND order_details.ProductID = products.productID
AND orders.ShipVia = shippers.ShipperID
ORDER BY products.productName";
$result = mysql_query($sql) or die(mysql_error());
// *MUST* have at least one row:
$row = mysql_fetch_assoc($result) or die(mysql_error());
// get things started:
$shipcost = $row["Freight"];
$shipvia = $row["shipCompany"];
$total = $shipcost;
// first output order header:
?>
<table border="1">
<tr>
<th>Company</th>
<th>Order#</th>
<th colspan="5"> </th>
</tr>
<tr>
<td><? echo $row["CompanyName"]; ?></td>
<td><? echo $orderid; ?></td>
<td colspan="7"> </td>
</tr>
<tr>
<th colspan="2"> </th>
<th>Product</th>
<th>Prod #</th>
<th>Quantity</th>
<th>Price</th>
<th>Cost</th>
</tr>
<?php
// now output one row per record for the order details:
while ( true )
{
$price = $row["UnitPrice"};
$qty = $row["quantity"]
$cost = $price * $qty;
$total += $cost;
?>
<tr>
<td colspan="2"> </td>
<td><? echo $row["ProductName"]; ?></td>
<td><? echo $row["ProductID"]; ?></td>
<td><? echo $qty; ?></td>
<td><? echo $price; ?></td>
<td><? echo $cost; ?></td>
</tr>
<?php
// try to get next row
$row = mysql_fetch_assoc($result);
if ( $row == FALSE ) { break; /* out of while loop */ }
} /* end of while loop
// ouput totals, etc.
?>
<tr>
<th colspan="5"> </th>
<th>Ship Via</th>
<th>Ship Cost</th>
</tr>
<tr>
<td colspan="5"> </td>
<td><? echo $shipvia; ?></td>
<td><? echo $shipcost; ?></td>
</tr>
<tr>
<td colspan="7"><br/></td>
</tr>
<tr>
<td colspan="6" style="text-align: right; font-weight: bold;">TOTAL</td>
<td><?echo $total; ?></td>
</tr>
</table>
</body>
</html>
How close is it to what you had?