I want to store two values in a database. A random number and a string. The string can sometimes be the same as other rows. I want the random number, when it's being stored, to be checked if it's an unique value in the table. If it is, it shall be stored and the number shall be printed on the screen. If not, the number shall change to another number, which is unique. Then the variable, which the number is stored in, should change to the new number.
Messy description? Perhaps. Please try and help my anyway.