android6011 Posted April 11, 2008 Share Posted April 11, 2008 I want to make sure a username doesnt exist before inserting it into a table, what is the best way for this? should i pull the value from the table as a variable and loop check it or pull it as an array? I'm just looking for the most efficient and best method. thanks Link to comment https://forums.phpfreaks.com/topic/100579-best-way-to-check-table-for-variable/ Share on other sites More sharing options...
awpti Posted April 11, 2008 Share Posted April 11, 2008 <?php $res = mysql_query("SELECT * FROM my_user_table WHERE Username = '{$some_username}'); if(mysql_num_rows($res) === 0) { //create new user } else { //User exists. } You get the idea Link to comment https://forums.phpfreaks.com/topic/100579-best-way-to-check-table-for-variable/#findComment-514414 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.