I need to generate a random number in the format 105-##### and I need to check this generated number against the already created numbers before saving it to the database to make sure it doesn't exist.
Here is my code to generate the number itself:
$digits = 5; $second_num = str_pad(rand(0, pow(10, $digits)-1), $digits, '0', STR_PAD_LEFT); $order_gen = "105-".$second_num;
Now that I have this $order_gen number, what is the best way to loop through what I already have in the order_number database table to make sure there are no duplicates? I was thinking of using a while loop but not sure how to apply it.