PHP help, search the table for the appropriate number-ThrowExceptions

Exception or error:

Hello I am very new in the field, and I have a kind of more true customer site, he asks me to find in the database a number between interest 43 and 45 and if there is a find then will show the requested number.

$random = rand(43,45);
$echo = "Sorry but no winner";

$rank1 = $db->query("SELECT * FROM `numbers_users`");
while ($rank = $rank1->fetch_assoc())   {

    $oud = details($rank['ID']);

    if($random == $rank['numbers']){
    $db->query("UPDATE `numbers` SET `win` = '".$rank['users']."',`numbers` = '".$random."'  WHERE 1");
    $error = $random;

}else {
    $db->query("UPDATE `numbers` SET `win` = '".$echo."'  WHERE 1);
    $error = $random;

This way works great but the problem is that it shows the last number in the table
This is the table I have, it only shows me the number 43 if it comes out 43.

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *