Hello folks, been a while,
Got a challenge for you, have been out of php programming for a while so trying to get back into it all.
Lets say i have 5 possible values (1,2,3,4,5). (in reality im going to have several million but this is an essential part of my program)
ok an input is produced (a) and the php generates it a value (5)
now this is stored in the database
5->(a)
another input is stored in the database(b) and the php generates it a value (2)
now
5->a
2->b
etc it goes on until the 5 values are taken up and there is no more possible values left to assign
ok, so my problem
I want the php to automatically generate a code, this has to be at random.
I know how to check the database to see if the value is taken or not, but lets say i input again(c) and the php generates code (5)
so i do a standard if and else and the else generates a new code (2)
the statement completes but the input still doesnt have a code.
How do i get this to keep generating a code untill a new and unique one is found. And is there a way to detect when all possible values (in this instance 1-5) are taken.
I have tried while but that doesnt seem to do as i want, maybe its my bad input.
Many thanks i hope this is clear enough for you.