Kullanılan toplam için Sum fonksiyonu ile al

0 Cevap php
    <?
$tablae = mysql_query("SELECT * FROM order_history where (type!='rent_referral' AND type!='rental_balance') AND date>'" . strtotime($time1) . "' AND date<'" . strtotime($time2) . "'  GROUP BY user_id"); 
while ($order = mysql_fetch_array($tablae)) { 

?>
<tr>
<?
$tablaes = mysql_query("SELECT * FROM members where id='$order[user_id]'"); 
$user = mysql_fetch_array($tablaes);
$idsd=$user['id'];
$rPaid=mysql_query("SELECT SUM(`price`) AS total FROM order_history WHERE (type!='rent_referral' AND type!='rental_balance') AND date>'" . strtotime($time1) . "' AND date<'" . strtotime($time2) . "'");
$hdPaid = mysql_fetch_array($rPaid);
$sPaid=mysql_query("SELECT SUM(`price`) AS total FROM order_history WHERE user_id='$idsd' AND (type!='rent_referral' AND type!='rental_balance') AND date>'" . strtotime($time1) . "' AND date<'" . strtotime($time2) . "'");
while ($hPaid = mysql_fetch_array($sPaid)) { 
?>
<td><?=$user['username']?></td>
<td><?=$hPaid['total']?></td>
<?  
}
?>

</tr>

<? } ?>

Bu bana, bu sonucu alır http://dl.dropbox.com/u/14384295/test.jpeg

Ben DESC tarafından fiyat toplamlarını sipariş etmek istiyorum.

Ben gerekir

$sPaid=mysql_query("SELECT SUM(`price`) AS total FROM order_history WHERE user_id='$idsd' AND (type!='rent_referral' AND type!='rental_balance') AND date>'" . strtotime($time1) . "' AND date<'" . strtotime($time2) . "'");

Bu konuda toplam DESC tarafından sipariş edilmesi.

0 Cevap