DarkPrince2005 Posted February 8, 2010 Share Posted February 8, 2010 Hi boys andd girls im trying to get a invoice sorted. The checkout of the shopping cart and everything else works perfectly, but I hit a snag with the proforma invoice that gets sent to the client. all orders are stored in the database and then retrieved and calculated with a mysql query, now my question is to make it echo or return the combined value of all the orders related to a particular session. It's currently only giving me the last item in the carts total as the grand total. But then aswel if the grand total is under 1900 an additional 85 should be added. while($record = mysql_fetch_assoc($result)) { $extprice = number_format($record['price'] * $record['a'], 2); if($record['total']>1900){ $grand_total = 85; }else{ $grand_total = 0; } $grand_total += $record['total']; $order_data .= " <tr> <td align=\"center\" valign=\"center\">{$record['a']}</td> <td align=\"center\">{$record['id']}</td> <td align=\"center\">{$record['name']}</td> <td align=\"center\">{$record['price']}</td> </td><td align=\"center\">{$record['total']}</td> </tr>"; } //Format the grand total $grand_total = number_format($grand_total, 2); Link to comment https://forums.phpfreaks.com/topic/191318-phpmysqladd-values-calculated-in-a-query/ Share on other sites More sharing options...
trq Posted February 8, 2010 Share Posted February 8, 2010 It's currently only giving me the last item in the carts total as the grand total. Makes perfect sense considering you don't appear to be adding to your $grand_total during each iteration of your loop. Link to comment https://forums.phpfreaks.com/topic/191318-phpmysqladd-values-calculated-in-a-query/#findComment-1008737 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.