Home >Backend Development >PHP Tutorial >怎么获取sql的SUM()值?紧急本人太菜

怎么获取sql的SUM()值?紧急本人太菜

WBOY
WBOYOriginal
2016-06-13 10:14:011115browse

如何获取sql的SUM()值?紧急!在线等!本人太菜
有一个表test1
字段名num
有三个字段 111 222 333

$sql=mysql_query("select SUM(num) from test1");

$a=xxx($sql);


接下来该用哪个函数xxx把666这个数取出来赋予变量啊???

万分感激

------解决方案--------------------
sql=mysql_query("select SUM(num) as t_sum from test1");
$res = mysql_fetch_array()
echo $res[t_sum]
------解决方案--------------------
$a=mysql_fetch_array($sql);
echo "

";<br>print_r($a);<br>echo "
";
------解决方案--------------------
sql=mysql_query("select SUM(num) as sum from test1"); 
$res = mysql_fetch_array() 
echo $res[sum]
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn