Ex.
$sql= mysql_query("SELECT SUM(shirt_sum) as total FROM tb_store_shirt WHERE shirt_name like 'เสื้อแจ็คเก็ต' ");
while($row=mysql_fetch_assoc($sql))
{
echo $row["total"];
}
$sql = "SELECT SUM(shirt_sum) AS total FROM tb_store_shirt WHERE shirt_name='$id'";
$result=mysql_db_query($dbname,$sql);
$row = mysql_fetch_array($result);
$total = $row["total"];//ผลรวม
ตอนนี้ใช้แบบนี้ครับ เครดิต thaiadmin.org/board/index.php?topic=101813.2