Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. <?php
  2. $servername = "co-project.lboro.ac.uk";
  3. $username = "crew13";
  4. $password = "fxs86tyv";
  5. $database = "crew13";
  6.  
  7. // Create connection
  8. $conn = new mysqli($servername, $username, $password, $database);
  9.  
  10. // Check connection
  11. if ($conn->connect_error) {
  12. die();
  13. }
  14.  
  15. $building = $_GET["building"];
  16.  
  17. $html = "<tr><th>Room</th><th>Building</th><th>Park</th><th>Capacity</th><th>Facilities</th></tr>";
  18. $sql = "SELECT roomID, building, park, capacity FROM Room WHERE building ='".$building."';";
  19. $result = $conn->query($sql);
  20. while($row = $result->fetch_assoc()) {
  21. $html = $html."<tr>";
  22. //Load room name
  23. $html = $html."<td>";
  24. $html = $html.$row['roomID'];
  25. $html = $html."</td>";
  26. //Load building name
  27. $html = $html."<td>";
  28. $html = $html.$row['building'];
  29. $html = $html."</td>";
  30. //Load park
  31. $html = $html."<td>";
  32. $html = $html.$row['park'];
  33. $html = $html."</td>";
  34. //Load capacity
  35. $html = $html."<td>";
  36. $html = $html.$row['capacity'];
  37. $html = $html."</td>";
  38. //Load facilities
  39. $html = $html."<td>";
  40. $sql2 = "SELECT facilityName FROM Facility WHERE facilityID IN (SELECT facilityID FROM Room_Facility WHERE Room_Facility.roomID = '".$row['roomID']."');";
  41. $result2 = $conn->query($sql2);
  42. while($row2 = $result2->fetch_assoc()) {
  43. $html = $html.$row2['facilityName'];
  44. $html = $html.", ";
  45. }
  46. $html = $html."</td></tr>";
  47. }
  48. echo '{"html": "'.htmlentities($html).'"}';
  49. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement