Learn, Share, Build

211
September 24, 2017, at 03:28 AM

I have a database for a homework, which holds hotel reservations.

I have to check for a reservation, based on a date.

for example:

2017-06-14

The query returns the room number, and print out the availability.

$selectedDay = $_POST['selectedDay'];
$select_date = "SELECT DISTINCT * FROM events WHERE '$selectedDay' BETWEEN start AND end - INTERVAL 1 DAY";
$result = mysqli_query($connection, $select_date);
echo "<h2>Free rooms in this date: <br/> $selectedDay</h2>";
if (mysqli_num_rows($result) > 0) {
    While ($row = mysqli_fetch_array($result)) {
        echo "<h3>" . $row['name'] . "</h3>";
        for ($i = 1; $i < 20; $i++) {
            if ($row['room' . $i] == '1') {
                echo "Room " . $i . ": <span style='color:red;'>busy</span> <br />";
            } else {
                echo "Room " . $i . ": <span style='color:green;'>free/span> <br />";
            }
        }
    }
} else {
    echo "No data for this date.";
}

I want ONE overall list of the rooms, now if there is 3 guest in the selected day, the list will be printed 3 times.

picture of the table: https://ibb.co/jBVcik

READ ALSO
Learn, Share, Build

Learn, Share, Build

After intalling Xampp on my MacThe address is http://192

199
Learn, Share, Build

Learn, Share, Build

I have a PHP function, that returns 'true' or 'false' based on if a particular data exists in Database/XML

199
Learn, Share, Build

Learn, Share, Build

Hello I am currently building a site with WordPress and wanted a drop down field where when a value was clicked it would change that element to the field specifiedI have looked for something similar but couldn't find any

186
Learn, Share, Build

Learn, Share, Build

First of all I'm new to SQL and to this website so I'm probably just doing some dummy errors

232