I basically want to create a unique login varchar in a table based of a first and last name.
So Jo Blob signs up and we go:
// check to see if username 'JoBlob' exists....
SELECT * FROM special_users WHERE username = $names[0] . $names[1]
// if it doesn't exist
INSERT INTO special_users username= $names[0] . $names[1]
// BUT if it does exist
// add some numbers to the username and insert
I'm curious how I can turn this into a function so that it would go through and then try JoBlob1 (if that exists, then) JoBlob2 (unless that exists), JoBlob3 etc etc and into infinity? I have some ideas but they seem excessively long ways around.
How should I approach this?