我想在所有行中添加金額。這裏是代碼。請幫助我。PHP添加行時出錯
$tot1=mysql_query("select SUM(Amount) from wp_product_details");
while($row1 = mysql_fetch_array($tot1))
{
echo $row1['Amount'];
}
我想在所有行中添加金額。這裏是代碼。請幫助我。PHP添加行時出錯
$tot1=mysql_query("select SUM(Amount) from wp_product_details");
while($row1 = mysql_fetch_array($tot1))
{
echo $row1['Amount'];
}
更改查詢一點點使用量與$row1[]
$tot1=mysql_query("select SUM(Amount) as Amount from wp_product_details");
或更改$row1[]
語法
while($row1 = mysql_fetch_array($tot1))
{
echo $row1['SUM(Amount)'];
}
在這段代碼中沒有結果 – raghu 2012-07-29 07:56:25
在phpmyadmin中試試這個sql查詢 – bugwheels94 2012-07-29 07:59:27
試試這個代碼
$tot1=mysql_query("select SUM(Amount) as amount from wp_product_details");
while($row1 = mysql_fetch_array($tot1))
{
echo $row1['amount'];
}
你有沒有嘗試$行[ 'SUM(金額)']? – Raiden 2012-07-29 07:50:12
我試過了,但沒有結果 – raghu 2012-07-29 07:52:03
試試這個:'選擇SUM(金額)作爲金額來自wp_product_details' – 2012-07-29 07:52:54