UPDATE instead of INSERT INTO

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I made an application which lets users rate web site content. At the heart of the application is this mySQL query: 

INSERT INTO `ratings` ( `reference` , `content_type` , `content_reference` , `language` , `ip_address` , `rating_timestamp` , `rating` ) VALUES ( NULL , '$content_type','$content_reference' , '$language', '$ip_address', NOW( ) , '$user_rating' ); 

I am wondering if there is a way to check if the user has already voted (IE If there is already a matching record with the same content_type, content_reference, language, ip_address values) so all that happens is an UPDATE to the rating field?

Ron

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux