就像@Thariaman所说的(+1)在MySql中不要那样做,因为将来麻烦和困难得多。
我会尝试这样的事情(用空键填充数组,因此如果您尝试访问它们(或其他东西),则脚本不会引发警告)
function getMaxScores($gameid) { $result = query("SELECt id, MAX(score) mscore FROM scores ". "WHERe id IN (".implode(',', $data).")". "GROUP BY id ORDER BY mscore DESC LIMIT 10" ); if(count($result) < 10) { $result = array_pad($result, 10, array("id" => "", "mscore" => ""); } return $result;}


