我正在尝试从MySQL数据库中的特定列汇总数据,然后将其回显到页面。我的代码如下:
<?php
//Trackingboard Display
$mysqli = new mysqli('localhost', 'root', '', 'disolDemo');
$query = $mysqli->query("SELECT sum(totLocMiles) FROM odoboard WHERE waybill_ID = '3'") or die($msqli->error);
$sumTot = mysql_fetch_array($query);
echo $sumTot[0];
?>
我做错了什么?
答案 0 :(得分:3)
您将mysqli
与mysql
试试这个
$mysqli = new mysqli('localhost', 'root', '', 'disolDemo');
$query = $mysqli->query("SELECT sum(totLocMiles) as sum FROM odoboard WHERE waybill_ID = '3'") or die($msqli->error);
while($row = $query->fetch_assoc())
{
echo $row['sum'];
}