$sqlCount = "SELECT count(id) FROM 表名 WHERE typeid= 1"; //typeid是栏目id //在数据库使用查询语句查询,然后拿到结果 $resultCount = $demo-> query($sqlCount); //输出中长度 if($resultCount){ $total = $resultCount -> fetch_assoc(); //count(id)总数 $dataCount = $total[count(id)]; } //把赋值给返回数据的total $outData['total'] = (int)$total["count(id)"];
