Ok I have hit my next hurdle. I have though of a few ways this could be done but just cannot wrap my head around it. What I would like to do is as I am accepting membership and move the member to the members database they will be given a member number with the following format of XXXX4XXX XXXX4000 and XXXX4001 are a reserved number. The new member should get the next lowest available. As members progress their stages they do end up changing their number making it available again.
So I accept the member it looks for the next lowest number available and are assigned it. I could theoretically have an XXXX4002 XXXX4018 XXXX4006 at any given time. The chance of having more than 50 members with this id format is probably unlikely.
I have though about selecting from the database all ID's that have XXXX4XXXX format and then placing them into an array and doing some sort of comparison or if statement so do this and setting this to my input variable.