You can use the ON DUPLICATE KEY UPDATE statement in your MySQL query when using PHP's mysqli or PDO libraries to accomplish this.