nicangeli Posted December 31, 2006 Share Posted December 31, 2006 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><?phprequire('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 More sharing options...
trq Posted December 31, 2006 Share Posted December 31, 2006 Just post your question here, its pretty hard to tell what variables you want to add up. Either way, its simple maths. Link to comment https://forums.phpfreaks.com/topic/32344-solved-working-out-a-total/#findComment-150179 Share on other sites More sharing options...
genericnumber1 Posted December 31, 2006 Share Posted December 31, 2006 [code]<h1><font face="verdana">View Order: <p></font face></h1><?phprequire('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 Link to comment https://forums.phpfreaks.com/topic/32344-solved-working-out-a-total/#findComment-150180 Share on other sites More sharing options...
nicangeli Posted December 31, 2006 Author Share Posted December 31, 2006 you really are a life saver thanks mate! Link to comment https://forums.phpfreaks.com/topic/32344-solved-working-out-a-total/#findComment-150181 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.