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? ??? Quote 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 } Quote 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! Quote Link to comment https://forums.phpfreaks.com/topic/95306-solved-controlling-duplicate-records/#findComment-488177 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.