I need to create a loop that will redo my query over and over until it posts something in the database.
if ($query_run = mysql_query($query)) {
while ($row = mysql_fetch_assoc($query_run)) {
$person = $row['firstname'];
$taken = $row['taken'];
if (isset($_COOKIE[$firstname])) {
echo "You've already drawn " . $_COOKIE[$firstname] . "!";
} else {
if (($person == ucfirst($firstname)) || ($taken == 1)) {
echo 'Redraw';
} else {
echo ucfirst($firstname) . " drew $person!";
setcookie($firstname, $person, time() + 30);
}
}
}
} else {
echo 'Query Failed';
}
Instead of echo ‘Redraw’; I need it to auto run a loop again because once they click the button the button is disabled.
I was thinking do while, but I cannot get it to work properly.
It could be accomplished like this:
But I’m not sure what its supposed to do. Most probably you meant something different.