Let's say I have given a user an access code. I have generated the code in php and would like to insert this random access code into the database, however it has to be unique to that user. So, when I have created the code and it checks to see if that code already exists in the database, if it returns true (as in, it is already existing), I want the script to "go back" or "loop" until it generates one that doesn't already exist.
I know how to generate the code, and how to insert into the mysql database. My question is simply, how would I go about writing the "loop" portion?