How-to articles, tricks, and solutions about SQL-INSERT
PHP MYSQL UPDATE if Exist or INSERT if not?
You can use the ON DUPLICATE KEY UPDATE statement in your MySQL query when using PHP's mysqli or PDO libraries to accomplish this.