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

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

WBOY
Release: 2016-06-13 10:14:01
Original
1120 people have browsed it

如何获取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 "
Copy after login
";
------解决方案--------------------
sql=mysql_query("select SUM(num) as sum from test1"); 
$res = mysql_fetch_array() 
echo $res[sum]
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template