remove records out of top 10
This commit is contained in:
1 parent
5de5f03b3c
commit
f12ff135fa
8 files changed
+67
-35
No files matched your search
@@ -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