How would I go about seeing if order id is taken and if it is taken then to make another one and see if its unique in the database.
I've got this prototype down however no luck. Doesn't execute if there is nothing in the database. Also doesn't do anything if order id is not unique.
$order_id = md5(uniqid(mt_rand(), true));
foreach($conn->query('SELECT * FROM `bucks-orders`') as $item){
if ($item['order-id'] != $order_id){
$insertOrder = "<sql code here>";
$conn->query($insertOrder);
break;
}
}