[Solved] Why my if…else statement doesnt work where is my mistake and how to fix it?


Please try this code:

    $number = 0;
    $result = mysqli_query($con, $sql);
    if (!$result) 
         exit(mysqli_error($con));
    else
         $number = mysqli_num_rows($result);
    if ($number==0) {
        echo "No rented cars for this period !";
    } else {
        while ($number){
            $row = mysqli_fetch_row($result);
            $brand = $row['brand'];
            $model = $row['model'];
            $reg_num = $row['reg_num'];
            $horse_powers = $row['horse_powers'];
            $color = $row['color'];
            echo $brand;
            $number--;
        }
    }

5

solved Why my if…else statement doesnt work where is my mistake and how to fix it?