1

MYSQL_FETCH_ARRAY から合計を追加しようとしていますが、乗算の価格を取得するために使用している JOINS が原因で、SELECT ステートメントで SUM を使用できません。

私のコードと、私が達成しようとしていることのスクリーンショットを以下に示します。

   $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 "<td>$".$formatted."</td>";

スクリーンショットはhttp://www.quarrygranite.com/ss.jpgで見ることができます。

ご協力いただきありがとうございます。

4

0 に答える 0