how to remove old scores from database for game high score tables
Page 1 of 1
how to remove old scores from database for game high score tables
- Code:
$con=mysqli_connect("localhost","root","password","database");
$count = mysqli_query($con,"SELECT * FROM highscores WHERE username = '$username'");
$count_check = mysqli_num_rows($count);
$new_count = $count_check - "1";
$new_count = "LIMIT $new_count";
mysqli_close($con);
$con=mysqli_connect("localhost","root","password","database");
mysqli_query($con,"DELETE FROM highscores WHERE username = '$username' ORDER BY score ASC $new_count");
mysqli_close($con);
Re: how to remove old scores from database for game high score tables
This script will count how many rows are in use for the currently logged in user
then it will delete all rows except the highest score for that user,
so i recommend inserting into the highscores table the newest high score first before deleting any rows that contain the lowest scores,
then this will only remove the rows with a less score and can be modified so that it can remove before inserting a new score but this is not recommended in case the lesser score is removed by accident!
you can also use ASC in your sql if it removes the wrong score so test this out and have fun, any comments please post here.
Please visit jnetscripts.com and tell all your friends about it, my name on there is multimedia.
then it will delete all rows except the highest score for that user,
so i recommend inserting into the highscores table the newest high score first before deleting any rows that contain the lowest scores,
then this will only remove the rows with a less score and can be modified so that it can remove before inserting a new score but this is not recommended in case the lesser score is removed by accident!
you can also use ASC in your sql if it removes the wrong score so test this out and have fun, any comments please post here.
Please visit jnetscripts.com and tell all your friends about it, my name on there is multimedia.
Similar topics
» Fancy PLaying A Game? what about a hacking game????????
» Authenticating against Django’s user database from Apache
» Bash Database Program Record Storage App
» linux database mysql workbench installation command
» Securing Your Linux Web Server PHPMYADMIN Database Login
» Authenticating against Django’s user database from Apache
» Bash Database Program Record Storage App
» linux database mysql workbench installation command
» Securing Your Linux Web Server PHPMYADMIN Database Login
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum