Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "co-project.lboro.ac.uk";
- $username = "crew13";
- $password = "fxs86tyv";
- $database = "crew13";
- // Create connection
- $conn = new mysqli($servername, $username, $password, $database);
- // Check connection
- if ($conn->connect_error) {
- die();
- }
- $building = $_GET["building"];
- $html = "<tr><th>Room</th><th>Building</th><th>Park</th><th>Capacity</th><th>Facilities</th></tr>";
- $sql = "SELECT roomID, building, park, capacity FROM Room WHERE building ='".$building."';";
- $result = $conn->query($sql);
- while($row = $result->fetch_assoc()) {
- $html = $html."<tr>";
- //Load room name
- $html = $html."<td>";
- $html = $html.$row['roomID'];
- $html = $html."</td>";
- //Load building name
- $html = $html."<td>";
- $html = $html.$row['building'];
- $html = $html."</td>";
- //Load park
- $html = $html."<td>";
- $html = $html.$row['park'];
- $html = $html."</td>";
- //Load capacity
- $html = $html."<td>";
- $html = $html.$row['capacity'];
- $html = $html."</td>";
- //Load facilities
- $html = $html."<td>";
- $sql2 = "SELECT facilityName FROM Facility WHERE facilityID IN (SELECT facilityID FROM Room_Facility WHERE Room_Facility.roomID = '".$row['roomID']."');";
- $result2 = $conn->query($sql2);
- while($row2 = $result2->fetch_assoc()) {
- $html = $html.$row2['facilityName'];
- $html = $html.", ";
- }
- $html = $html."</td></tr>";
- }
- echo '{"html": "'.htmlentities($html).'"}';
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement