Jump to content

php,mysql,add values calculated in a query


DarkPrince2005

Recommended Posts

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);

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.