remove records out of top 10
This commit is contained in:
@ -8,6 +8,14 @@
|
||||
}
|
||||
$query = $db->prepare('INSERT INTO `leaderboard` (`player`, `score`) VALUES (:player, :score);');
|
||||
$query->execute(array("player" => strip_tags($_POST['player']), "score" => (int) $_POST['score']));
|
||||
|
||||
$RowsToDelete = $db->query('SELECT id FROM `leaderboard` ORDER BY score DESC LIMIT 10, 10;');
|
||||
while($row = $RowsToDelete->fetch()) {
|
||||
$id = $row['id'];
|
||||
$db->query("DELETE FROM `leaderboard` WHERE id=" . $row['id'] . ";");
|
||||
}
|
||||
$row->closeCursor();
|
||||
$db->close();
|
||||
} else {
|
||||
header($_SERVER["SERVER_PROTOCOL"] . " 405 Method Not Allowed", true, 405);
|
||||
}
|
||||
|
Reference in New Issue
Block a user