Advertisement
Guest User

Untitled

a guest
Feb 19th, 2013
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. <?php
  2. require_once("../resources/php/connection.php");
  3.  
  4. $park = $_POST["park"];
  5. $lecturestyle_id = $_POST["lecturestyle"];
  6. $group_size = $_POST["groupsize"];
  7. $roomstructure_id = $_POST["roomstructure"];
  8. $array = explode(",", $_POST["facilities"]);
  9.  
  10. // change Mon here
  11. echo '<td class="gridSide">Mon';
  12.  
  13. // build facilities search
  14. echo '</td>';
  15.  
  16. $fac = null;
  17. for($i = 0; $i < count($array); $i++){
  18. if ($array[$i]!=0) {
  19. $fac .= ' AND facilities_id='.$array[$i].'';
  20. }
  21. }
  22.  
  23. for ($i = 1; $i <= 9; $i++){
  24.  
  25. // change mon here
  26. echo '<td class="box" id="mon'.$i.'">';
  27.  
  28. // dynamically build sql query
  29. $sql ="SELECT DISTINCT COUNT(*) FROM ts_room rm
  30. LEFT JOIN ts_roomfacilities rf
  31. ON rm.id = rf.room_id
  32. LEFT join ts_facilities f
  33. ON f.id = rf.facilities_id
  34. LEFT JOIN ts_building b
  35. ON rm.building_id=b.id
  36. WHERE capacity >= :group_size";
  37.  
  38. $sql .= $fac;
  39.  
  40. if($park!="Any") {
  41. $sql .= " AND b.park_id=:park";
  42. $searchArray[':park'] = $park;
  43. }
  44.  
  45. if($lecturestyle_id!="Any") {
  46. $sql .= " AND lecturestyle_id=:lecturestyle_id";
  47. $searchArray[':lecturestyle_id'] = $lecturestyle_id;
  48. }
  49.  
  50. if($roomstructure_id!="Any") {
  51. $sql .= " AND roomstructure_id=:roomstructure_id";
  52. $searchArray[':roomstructure_id'] = $roomstructure_id;
  53. }
  54.  
  55. $sql .= " AND rm.id NOT IN
  56. (SELECT COUNT(*)
  57. FROM ts_request rq
  58. LEFT JOIN ts_allocation a ON a.request_id = rq.id
  59. WHERE
  60. day_id=1 AND period_id=:period
  61. OR a.status IS NOT NULL
  62. AND a.status IN ('Pending','Declined','Failed'))";
  63.  
  64. //Dont forget these
  65.  
  66. $searchArray[':period'] = $i;
  67. $searchArray[':group_size'] = $group_size;
  68.  
  69. $stm = $pdo->prepare($sql);
  70. $stm->execute($searchArray);
  71. $rows = $stm->fetchColumn();
  72.  
  73. echo $rows.'<br>free</td>';
  74. echo '</td>';
  75.  
  76. }
  77. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement