SQL同一个表,PHP分别查询2列数据的总和然后输出
程序员文章站
2022-05-04 12:59:07
...
//计算订单数量的总和
$query_num = "SELECT SUM(order_num) from hcf_order_db where order_id = XXX";
$arr_qn = mysqli_query($dbc,$query_num);
list($sum)=mysqli_fetch_row($arr_qn);
//计算订单金额的总和
$query_amount = "SELECT SUM(order_amount) from hcf_order_db where order_id = XXX";
$arr_qm = mysqli_query($dbc,$query_amount);
list($sum2)=mysqli_fetch_row($arr_qm);
然后就是PHP输出:
tdclass='font-songti'align='center'>