通常,尽量避免在循环内进行查询.相反,加入表格.
$sql = "SELECT SUM(xb_end_range) AS punten FROM club AS c JOIN players_db AS p ON c.speler_id = p.id WHERE c.user_id = $userid"; $result = mysql_query($sql); $row = mysql_fetch_assoc($result); $punten = $row['punten']; echo $punten;