function setScoreByPlayerName($playerName, $newScore) { $connection = open_database_connection(); $oldScore = getScoreByPlayerName($playerName); $playerId = getIdByPlayerName($playerName); $shouldUpdate = $newScore > $oldScore; if ($shouldUpdate) { //--------- // update Score // $query = "UPDATE highscores SET Score={$newScore} WHERE id={$playerId}"; mysqli_query($connection, $query); $numAffectedRows = mysqli_affected_rows($connection); close_database_connection($connection); return $numAffectedRows > 0; } else { close_database_connection($connection); return false; } }
function getPlayer() { $playerName = $_GET["Name"]; $Score = getScoreByPlayerName($playerName); print $Score; }