Need to total values from a MYSQL FETCH ARRAY?
<p>I am trying to add the totals from a MYSQL_FETCH_ARRAY and I cannot use SUM in the SELECT statement due to the JOINS i am using to get pricing for multiplication.</p>

<p>My code is below as well as a screenshot as to what I am trying to accomplish.</p>

<pre><code>   $qt2 = mysql_query("SELECT
   customer_specs.type, 
   customer_specs.stone, 
   customer_specs.sf,
   customer_specs.bs_ht,
   customer_specs.edge_1_lf,
   customer_specs.tearout_1_price, 
   customer_specs.tearout_1_sf, 
   customer_specs.cooktop_cutout_qty, 
   customer_specs.cooktop_cutout_price, 
   customer_specs.elect_outlet_qty, 
   customer_specs.elect_outlet_price, 
   customer_specs.sink_1_cutout, 
   customer_specs.sink_2_cutout,  
   stones.price AS stprice, 
   edging.price AS edprice, 
   s1.name AS s1name, 
   s2.name AS s2name, 
   s1.price AS s1price, 
   s2.price AS s2price  

   FROM customer_specs 
    INNER JOIN items 
    ON customer_specs.type=items.id
    INNER JOIN stones 
    ON customer_specs.stone=stones.id
    INNER JOIN edging 
    ON customer_specs.edge_1=edging.id
    INNER JOIN sinks AS s1 
    ON customer_specs.sink_1=s1.id
    INNER JOIN sinks AS s2 
    ON customer_specs.sink_2=s2.id

    WHERE quote = '$qte' AND c_id='$cid'");         
    while($qts2 = mysql_fetch_array( $qt2 )) 
    { 
    $edgep = $qts2['edprice'] * $qts2['edge_1_lf'];
    $stonep = $qts2['stprice'] * $qts2['sf'];
    $tearp = $qts2['tearout_1_sf'] * $qts2['tearout_1_price'];
    $cookp = $qts2['cooktop_cutout_price'] * $qts2['cooktop_cutout_qty'];
    $elecp = $qts2['elect_outlet_price'] * $qts2['elect_outlet_qty'];
    $sink1cp = $qts2['sink_1_cutout'];
    $sink2cp = $qts2['sink_2_cutout'];
    $sink1p = $qts2['s1price'];
    $sink2p = $qts2['s2price'];

    $total = $edgep + $stonep + $tearp + $cookp + $elecp + $sink1cp + $sink2cp+$sink1p + $sink2p;
    $money=$total;
    $formatted = number_format($money,2);
    Print "&lt;td&gt;$".$formatted."&lt;/td&gt;";
</code></pre>

<p>Screenshot can be seen at: <a href="http://www.quarrygranite.com/ss.jpg" rel="nofollow">http://www.quarrygranite.com/ss.jpg</a></p>

<p>Thanks in advance for any assistance.</p>
