f ($is_it_there==$name AND $result>$is_it_there2 AND $result>$is_it_there3) { mysql_query("UPDATE highscore SET result='$result' WHERE nickname='$name'")or die("<br /><br />ERROR: Updating Highest Score failed!"); echo "<br /><br /><b><font color='red'>Your Highest score has been updated.</font></b><br /><a href='index.php'>GO BACK</a>"; }
Całość kodu to:
// Get values from form $name=$_POST['nickname']; $result=$percent; // Connect to server and select database. $choose = "SELECT nickname FROM highscore WHERE nickname='$name'"; $is_it_there = $chosen['nickname']; $choose2 = "SELECT result FROM highscore WHERE nickname='$name'"; $is_it_there2 = $chosen2['result']; $choose3 = "SELECT result2 FROM highscore WHERE nickname='$name'"; $is_it_there3 = $chosen3['result2']; if ($is_it_there==$name AND $result>$is_it_there2 AND $result>$is_it_there3) { mysql_query("UPDATE highscore SET result='$result' WHERE nickname='$name'")or die("<br /><br />ERROR: Updating Highest Score failed!"); echo "<br /><br /><b><font color='red'>Your Highest score has been updated.</font></b><br /><a href='index.php'>GO BACK</a>"; } elseif ($is_it_there==$name AND $result>$is_it_there2 AND $result<$is_it_there3) { mysql_query("UPDATE highscore SET result='$result' WHERE nickname='$name'")or die("<br /><br />ERROR: Updating Highest Score failed!"); mysql_query("UPDATE highscore SET result2='$result' WHERE nickname='$name'")or die("<br /><br />ERROR: Updating Lowest Score failed!"); echo "<br /><br /><b><font color='red'>Your Highest and Lowest score have been updated.</font></b><br /><a href='index.php'>GO BACK</a>"; } elseif ($is_it_there==$name AND $result<$is_it_there2 AND $result<$is_it_there3) { mysql_query("UPDATE highscore SET result2='$result' WHERE nickname='$name'")or die("<br /><br />ERROR: Updating Lowest Score failed!"); echo "<br /><br /><b><font color='red'>Your Lowest score has been updated.</font></b><br /><a href='index.php'>GO BACK</a>"; } elseif ($is_it_there==$name AND $result<$is_it_there2 AND $result>$is_it_there3) { echo "<br /><br /><b><font color='red'>Your Lowest or Higest score have NOT been updated. This attempt is NOT your highest/lowest.</font></b><br /><a href='index.php'>GO BACK</a>"; } elseif ($is_it_there!=$name) { // Insert data into mysql $sql="INSERT INTO $tbl_name(result, nickname, result2)VALUES('$result', '$name', '$result')"; // if successfully insert data into database, displays message "Successful". if($result){ echo "<br /><br /><b><font color='red'>New Highscore for this nick! Score saved.</font></b><br /><a href='index.php'>GO BACK</a>"; } else { echo "<br /><br /><b><font color='red'>ERROR: If you spot this error after refreshing this page please ignore. If not - report to Cromiell.</font></b>"; } }