I'm generating a random code, and I need to check to be sure that the code isn't already in the database. I'm assuming this requires some type of a loop. I have my query all setup and I need it to run a block of code again if mysql_num_rows == 0
.
PHP 7 requires a return . A break; is not needed because the loop ends on return . A break; is usually used in a switch or loop whenever you have found your needed item.
while is a pre-conditioned loop, and do.. while is post-conditioned loop. That means - in while a condition is checked before iteration, and in do.. while - after iteration.
$key = true;
while($key){
// Do stuff
if(mysql_num_rows($result) > 0) $key = false;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With