0
我在这里查询这个查询,为了得到某个列的总和,但是我总是收到错误Undefined index
。从查询中检索SUM结果的问题
$sql_shuma="SELECT SUM(vlera) AS shuma "
."FROM servis_pjeset_perdorura "
."WHERE random = $random";
$resultshuma = odbc_exec($connection, $sql_shuma) or die(odbc_error());
while($rowshuma = odbc_fetch_array($resultshuma)) {
echo $total1 = $rowshuma['shuma'];
}
?>
我在这里做错了什么?也许这是$total1
的值,我不知道如何保存结果。
谢谢
它似乎是PHP而不是SQL问题。我建议你在你的文章中加入[PHP]标签。 – 2013-03-07 14:06:28
做一个'print_r($ rowshuma)'看看里面有什么。根据用户对[odbc_fetch_array()文档](http://us3.php.net/manual/en/function.odbc-fetch-array.php)的评论,它可能并不总是返回一个关联数组。键可以是数字。 – 2013-03-07 14:17:23