pumaf1 Posted October 5, 2007 Share Posted October 5, 2007 hi, I am writing a fantasy f1 system for 2008. What I have so far is the system taking the records perfectly fine but I want it to check to see if a few things have been duplicated 1 - username the login system uses sessions and i have the users name as the team owners name. I want it to check to see if the user has already registered a team, and if so i want it to say "you already have a team." 2 - teamname pretty much the same as the above - aka that team name is already in use. I dont want it to check all the fields as some will be duplicates within the database. If anyone could point me in the right firection i would be really gratefull. thanks Link to comment https://forums.phpfreaks.com/topic/71989-checking-if-a-record-exists/ Share on other sites More sharing options...
MmmVomit Posted October 5, 2007 Share Posted October 5, 2007 <?php $sql = "SELECT * FROM table WHERE team_name = '$team_name';"; $result = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($result) > 0) { // team already registered } else { // team not registered } ?> Do the same thing for username. Link to comment https://forums.phpfreaks.com/topic/71989-checking-if-a-record-exists/#findComment-362661 Share on other sites More sharing options...
kathas Posted October 5, 2007 Share Posted October 5, 2007 Also to make sure that there is no duplicate entry of a specific field in your DB you could declare it as unique... See the DB manual... I have MySQL's linked here ( It has a lot of info but you can find what you need if you look at COLUMN DEFINITIONS ) Link to comment https://forums.phpfreaks.com/topic/71989-checking-if-a-record-exists/#findComment-362671 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.