query("SELECT score FROM tetris WHERE pseudo = '$pseudo';"); $result = $query->rowCount(); if($result == 0) { $query = $bdd->query("INSERT INTO tetris (date, pseudo, score, ip) VALUES ('$date', '$pseudo', '$score', '$ip');"); $reponse = "v"; } else { while($donnee = $query->fetch()) { $current_score = $donnee['score']; } if($score >= $current_score) { $query = $bdd->query("UPDATE tetris SET date = '$date', score = '$score', ip = '$ip' WHERE pseudo = '$pseudo';"); $reponse = "v"; } else { $reponse = "m"; } } } else { $reponse = "n"; } echo json_encode($reponse);