Mysql查询不显示列的总和

时间:2014-01-13 14:26:37

标签: php mysql

知道为什么这不起作用?当我运行它时,它不会显示任何内容。

$qry = mysql_query(" SELECT SUM(payment_received) AS total FROM Orders ");
   {
 $row = mysql_fetch_assoc($qry);
echo $row['total'];
}

感谢您的帮助。

2 个答案:

答案 0 :(得分:1)

$result = mysql_query("SELECT SUM(payment_received) AS total FROM Orders") or die(mysql_error());
$row = mysql_fetch_assoc($result);
print_r($row);

答案 1 :(得分:1)

使用以下示例

更正您的代码
$qry = mysql_query("SELECT SUM(payment_received) AS total FROM Orders");
while ($row = mysql_fetch_assoc($qry)) {
{
    echo $row["total"];
}