各位高手:
    我使用的查询语句为:select sum(quantity) from table_name,在命令行环境下能够获得数量字段的汇总值,但不知在PHP中如何来操作查询得到的汇总值,请各位指教,谢谢。

解决方案 »

  1.   

    select sum(quantity) AS myname from table_name$Result['myname']
      

  2.   

    和count()的用法一个样吧, as 赋给一个随便的值
    其实google一下全知道 http://yp.oss.org.cn/software/show_resource.php?resource_id=87
      

  3.   

    ca。来看看。蛋疼的写个例子。
    <?php 
      $conn = mysql_connect(...........);
      mysql_query("set names 'utf8'");
      $sql = "select sum('quanlity') as sumq from table_name";
      $res = mysql_query($sql);
      $result = mysql_fetch_array($res);
      $total = $result['sumq'];
      echo $total;
    ?>