PHP+MYSQL筛选字段并求和的一段代码写法,在线等!!

2025-01-07 20:08:24
推荐回答(1个)
回答1:

$con = mysql_connect("localhost", "root", "321");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db("test_db",$con);
$sql="select sum(posts) from forum where fup=1";
$result = mysql_query($sql,$con);
$row=mysql_fetch_row($rset);
echo $row[0];
mysql_close($con);
?>