php不懂,
SQL 写给你
SELECT user, SUM(shul) shul FROM h_user GROUP by user
$link=mysql_connect(localhost,用户名,密码);//连接mysql数据库
mysql_select_db(mysql数据库名);//选择数据库名
$sql="select user,count(shul) as sumshul from h_user group by user";//定义查询语句
$result=mysql_query($sql);//执行查询
echo "
".$row[user]." | ".$row[sumshul]." |
$sql="select user,sum(shul) from h_user group by user ";
$result=mysql_query($sql);
$arr=mysql_fetch_array($result);
foreach($arr as $k=>$v){
echo $v[0].''.$v[1];
}
select user,sum(shul) from h_user group by user