I have table named “highscore” like this:
nameQL scoreQL
piotr 50
And flash game with NAME and SCORE exported to PHP with this names.
How to make this in PHP file:
- IF (NAME exists in database (nameQL)
AND SCORE> this.name.scoreQL){Raplace scoreQL
with SCORE WHERE nameQL=NAME} - IF (NAME doesn’t exists){Create
new row with NAME and SCORE)
I would use
insert .. on duplicate key update ...statement. Something like this:namecolumn should be indexed asunique.Test script:
Output of
select * from player: