joshblue Posted March 10, 2008 Share Posted March 10, 2008 Hi! Can somebody give me an idea or a simple code that could control duplicate records in PHP/MySQL? ??? Link to comment https://forums.phpfreaks.com/topic/95306-solved-controlling-duplicate-records/ Share on other sites More sharing options...
teng84 Posted March 10, 2008 Share Posted March 10, 2008 you can use unique as your fields property.. or check first before inserting eg... $user = $_POST['user']; $query = " select * from table where name = '$user'"; $result =mysql_query($query); if(mysql_num_rows($result)<=0){ //INSERTHERE }else{ //dontinsert } Link to comment https://forums.phpfreaks.com/topic/95306-solved-controlling-duplicate-records/#findComment-488160 Share on other sites More sharing options...
joshblue Posted March 10, 2008 Author Share Posted March 10, 2008 you can use unique as your fields property.. or check first before inserting eg... $user = $_POST['user']; $query = " select * from table where name = '$user'"; $result =mysql_query($query); if(mysql_num_rows($result)<=0){ //INSERTHERE }else{ //dontinsert } Got it! Thanks! Link to comment https://forums.phpfreaks.com/topic/95306-solved-controlling-duplicate-records/#findComment-488177 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.