Jump to content

[SOLVED] working out a total


nicangeli

Recommended Posts

hello everybody,
i would really appreciate help with this matter, (i am no code expert!)

please view the image to understand my problem,
[code]<h1><font face="verdana">View Order: <p></font face></h1>
<?php
require('config.php');
echo "Order id: " . $_GET[id] . "<br>";
?>
<table width="472" height="48" border="1" cellpadding="0" cellspacing="0">
  <tr>
    <td>Item</td>
    <td>Quantity</td>
    <td>Price (Each £)</td>
    <td>Total £ </td>
  </tr>
  <?php
$query2 = mysql_query("SELECT orders.orderid, orderdetails.orderid, orderdetails.item, orderdetails.price, orderdetails.quantity FROM orders, orderdetails WHERE
(orderdetails.orderid = orders.orderid and orders.orderid = '$_GET[id]')");

while($array2 = mysql_fetch_array( $query2 ))
{
echo "<tr><td>" . $array2[item] . "</td>" . "<td>" . $array2[quantity] . "</td>" . "<td>" . $array2[price] . "</td><td>" . $array2[quantity]*$array2[price] . "</td></tr>";
}
echo "<tr><td>Total</td><td>--</td><td>--</td><td>Total Here</td></tr>";

?>[/code]
[url=http://img139.imageshack.us/my.php?image=helpck8.jpg][img=http://img139.imageshack.us/img139/6213/helpck8.th.jpg][/url]
Link to comment
https://forums.phpfreaks.com/topic/32344-solved-working-out-a-total/
Share on other sites

[code]
<h1><font face="verdana">View Order: <p></font face></h1>
<?php
require('config.php');
echo "Order id: " . $_GET[id] . "<br>";
?>
<table width="472" height="48" border="1" cellpadding="0" cellspacing="0">
  <tr>
    <td>Item</td>
    <td>Quantity</td>
    <td>Price (Each £)</td>
    <td>Total £ </td>
  </tr>
  <?php
$query2 = mysql_query("SELECT orders.orderid, orderdetails.orderid, orderdetails.item, orderdetails.price, orderdetails.quantity FROM orders, orderdetails WHERE
(orderdetails.orderid = orders.orderid and orders.orderid = '$_GET[id]')");
$total = 0;
while($array2 = mysql_fetch_array( $query2 ))
{
echo "<tr><td>" . $array2[item] . "</td>" . "<td>" . $array2[quantity] . "</td>" . "<td>" . $array2[price] . "</td><td>" . $array2[quantity]*$array2[price] . "</td></tr>";
$total += $array2['quantity']*$array2['price'];
}
echo "<tr><td>Total</td><td>--</td><td>--</td><td>{$total}</td></tr>";

?>
[/code]

that should do it

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.