添加行时PHP错误

时间:2012-07-29 07:48:55

标签: php mysql add

我想在所有行中添加金额。这是代码。请帮助我。

$tot1=mysql_query("select SUM(Amount) from wp_product_details"); 
while($row1 = mysql_fetch_array($tot1))
{
echo $row1['Amount'];
}

2 个答案:

答案 0 :(得分:2)

稍微更改您的查询以使用$row1[]

的金额
$tot1=mysql_query("select SUM(Amount) as Amount from wp_product_details"); 

或者更改$row1[]语法

while($row1 = mysql_fetch_array($tot1))
{
echo $row1['SUM(Amount)'];
}

答案 1 :(得分:0)

试试此代码

 $tot1=mysql_query("select SUM(Amount) as amount from wp_product_details"); 
    while($row1 = mysql_fetch_array($tot1))
    {
    echo $row1['amount'];
    }