0

我有这张表,它只是减去从 recv 移动销售的手机,而不是显示在平衡手机中,还加上旧行余额和新行。

|Received Mobiles |Mobile i have sold | Balance |
|6                |1                  |  5 
|3                |2                  |  6
|4                |2                  |  8 ----------> total mobiles i have      

但我想反转(计算从最后开始)这个结果并想这样显示,因为我想在顶部看到新记录

|Received Mobiles |Mobile i have sold | Balance |
|6                |1                  |  8 ----------> total mobiles i have
|3                |2                  |  3
|4                |2                  |  2 <------- plus with recv mob 3 then - sold mob   

我在写这个

while ($fetch = mysql_fetch_array($query)) {

$recvtotal += $fetch[recv];
$soldtotal += $fetch[sold];

$balancing += $fetch[recv]-$fetch[sold];
echo "<tr>";
echo "<td>" . $fetch[brand] . "</td>";
echo "<td>" . $fetch[recv] . "</td>";
echo "<td>" . $fetch[sold] . "</td>";
echo "<td>" . ($balancing) . "</td>";

echo "</tr>";


}
4

1 回答 1

2

为什么不在查询中添加排序?只需添加一个ORDER BY子句,您应该可以颠倒顺序。

于 2013-08-17T12:39:52.283 回答