On submitting (ID, username, score), I only want the database to update if the score is higher than the usernames previous score.
So far I have
$sql = mysqli_query($con, "INSERT INTO $db_name.$db_table (ID, name, score)
VALUES ((ID, name , score) IF $ID=ID & $name=name & '$score'>score);");
Full code is
if(isset($_GET['ID']) & isset($_GET['name']) & isset($_GET['score'])){
$con = mysqli_connect($host, $db_username, $db_password, $db_name);
$ID = strip_tags(mysqli_real_escape_string($con, $_GET['ID']));
$name = strip_tags(mysqli_real_escape_string($con, $_GET['name']));
$score = strip_tags(mysqli_real_escape_string($con, $_GET['score']));
$sql = mysqli_query($con, "INSERT INTO $db_name.$db_table (ID, name, score)
VALUES ((ID, name , score) IF $ID=ID & $name=name & '$score'>score);");
if($sql){
//The query returned true - now do whatever you like here.
echo 'Your score was saved. Congrats!';
}else{
//The query returned false - you might want to put some sort of error reporting here. Even logging the error to a text file is fine.
echo("<br>Error description: " . mysqli_error($con));
}
mysqli_close($con);//Close off the MySQLI connection to save resources.