我在兩個不同的while循環中從數據庫中獲取數據,我想在循環之外在它們之間添加變量。例如:在兩個不同的while循環中添加數字
while($cash_fetch = mysql_fetch_array($cash_qur))
{
$a = 500; //suppose I am fetching from database
}
while($card_fetch = mysql_fetch_array($card_qur))
{
$b = 1000; //suppose I am fetching from database
}
$total = $a+$b;
echo $total;
我想要完全做這件事,但我得到不適當的結果。請幫忙。