fer0an Posted January 25, 2010 Share Posted January 25, 2010 hello I've a db with some data I want to check content, if title dosen't exist create it and if exist continue. My db column is -->id--title--introtext--fulltext--link anyone can help me? Link to comment https://forums.phpfreaks.com/topic/189685-check-duplicate/ Share on other sites More sharing options...
SchweppesAle Posted January 25, 2010 Share Posted January 25, 2010 Something like this i guess. $title = 'blahblah'; /*leave out the * in yourtablename*/ $query = "SELECT * FROM *yourtablename* WHERE title = '$title'"; $result = mysql_query($query); if(mysql_num_rows($result) == 0) { $query = "INSERT INTO *yourtablename* (id,title,introtext,fulltext,link) VALUES (NULL,Titleblahblah,fulltextblahblah,linkblahblah)"; $result = mysql_query($query); if(!result) { die("problem inserting data: ".mysql_error()); } } Link to comment https://forums.phpfreaks.com/topic/189685-check-duplicate/#findComment-1001096 Share on other sites More sharing options...
fer0an Posted January 25, 2010 Author Share Posted January 25, 2010 Thank you Link to comment https://forums.phpfreaks.com/topic/189685-check-duplicate/#findComment-1001098 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.