mercredi 19 avril 2017

PHP if statement evaluating to false, proceeds into executing true code. am i missing something?

I have a problem with my php code. I am making a reservation app and so far so good. I am a beginner so my code might seem a little akward but please i can't seem to figure this one out even after trying some things.

    $sql1 = "SELECT COUNT(*) as total FROM tables WHERE status_id = 1 AND chair_count = 2 AND (section_id = 3 OR section_id = 4)";
    $result = mysqli_query($conn, $sql1);
    $tableCount = mysqli_fetch_assoc($result);
    //Availability info for users
        if($tableCount > 0){
            echo "Available tables: " . $tableCount['total']. " " . "<br><br>";
            //query for displaying available tables   
            $sql2 = "SELECT * FROM tables WHERE status_id = 1 AND chair_count = 2 AND (section_id = 3 OR section_id = 4)";
            $result = mysqli_query($conn, $sql2);
            while ($row = mysqli_fetch_assoc($result)) {
                array_push($availableTables,$row['tableid']);
                $resTable1 = $availableTables[array_rand($availableTables)];
            }

the code above is a query that determines if there are any available tables. if so another query is executes yada yada, thats working fine.

            }else{
                echo "Cant make reservation before today" . "(Inserted Date = " . $reservationDate . ") & " . "(Current Date = " . $today . ")" . "<br>";
            }

this is the last part that closes the if statement then proceeds to an else that wont appear.

What am i missing? Thanks in advance i appreciate it a lot!!

Aucun commentaire:

Enregistrer un commentaire