I have the following query:
$sqltext = "SELECT Score FROM HighScore ".
"WHERE fbID='$_POST[fbID]' AND ".
"Layout='$_POST[Layout]'";
$result = mysql_query($sqltext);
if(mysql_num_rows($result)>0){
$sql = "UPDATE HighScore SET Score = '$_POST[Score]', ".
"Time = '$_POST[Time]', ".
"Stars = '$_POST[Stars]' ".
"WHERE fbID = '$_POST[fbID]' AND Layout = '$_POST[Layout]'";
} else {
$sql = "INSERT INTO HighScore (fbID, Layout, Score, Time, Stars) ".
"VALUES ('$_POST[fbID]','$_POST[Layout]',".
"'$_POST[Score]','$_POST[Time]','$_POST[Stars]')";
}
What does it do? Well it checks if a row is in the database or not (there is always just 1 row or none). If there is no row, it inserts a new one in the database. If the row is present it will update the row. This all works OK.
$sqltext will give a value. This value can be 234, 3424342 or even -392. If this value is smaller than the ‘$_POST[Score]’ value, it should update the row. Currently it doesn’t and I can’t seem to get this working properly. So how can I make it so, that if $sqltext (which is Score from the db) < ‘$_POST[Score]’ it should update the row and else ignore it? (also not insert).
I think this is what you want. But it does not do anything, if there is a row AND the score is higher than the Score in POST[‘Score’]