【发布时间】:2015-05-31 06:21:47
【问题描述】:
我正在尝试从我的选择查询中获取最后一行的值。
这是我使用 ADODB 的 PHP 查询:
$con->Execute("SET @depos=0");
$con->Execute("SET @total=$openingbalance");
$sql = "SELECT if( credit >0, @depos := credit , @depos := @depos + credit - debit ) AS depos_bal, @total := @total + `credit` - `debit` AS net_bal FROM `table` WHERE `mydate` < '".$monthstarts."' ORDER BY `mydate` ASC, `credit` DESC";
$ssresults=$con->Execute($sql);
$fnew = $ssresults->getrows();
for($i=0;$i<count($fnew);$i++)
{
$bal = $fnew[$i]['net_bal'];
}
echo $bal;
这里我想从循环中获取最后一行的值。
例如:
Balance
----------
150.00
250.00
350.00
600.00
850.52 <----- this is the row I want to fetch from the query.
我怎样才能得到这个?请帮忙!
【问题讨论】: