Advertisement
Guest User

Untitled

a guest
Jan 25th, 2017
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.76 KB | None | 0 0
  1. <?php
  2. require_once 'users/init.php';
  3. require_once $abs_us_root.$us_url_root.'users/includes/header.php';
  4. require_once $abs_us_root.$us_url_root.'users/includes/navigation.php';
  5. ?>
  6. <?php
  7. if(!empty($_POST)){
  8. $project = Input::get('project');
  9. $volunteer = Input::get('volunteer');
  10. $small_animals = Input::get('small_animals');
  11. $large_animals = Input::get('large_animals');
  12. $animal_habitat = Input::get('animal_habitat');
  13. $environment = Input::get('environment');
  14. $habitat = Input::get('habitat');
  15. $something = Input::get('something');
  16. $children = Input::get('children');
  17. $elderly = Input::get('elderly');
  18. $disabled = Input::get('disabled');
  19. $homeless = Input::get('homeless');
  20.  
  21. $matches = [];
  22.  
  23. if($project == 1){ //it's getting this from the value of the checkbox
  24. $project = '1';
  25. $projectQ=$db->query("SELECT id FROM users WHERE project = ? ",array($project));
  26. $project=$projectQ->results();
  27. foreach ($project as $c){
  28. array_push($matches,$c);
  29. }
  30. }
  31.  
  32. if($volunteer == 1){
  33. $volunteer = '1';
  34. $volunteerQ=$db->query("SELECT id FROM users WHERE volunteer = ? ",array($volunteer));
  35. $volunteer=$volunteerQ->results();
  36. foreach ($volunteer as $c){
  37. array_push($matches,$c);
  38. }
  39. }
  40.  
  41. if($small_animals == 1){
  42. $smallanimals = "small animals";
  43. $small_animalsQ=$db->query("SELECT id FROM users WHERE small_animals = ? ",array($smallanimals));
  44. $small_animals=$small_animalsQ->results();
  45. foreach ($small_animals as $c){
  46. array_push($matches,$c);
  47. }
  48. }
  49.  
  50. if($large_animals == 1){
  51. $largeanimals = "large animals";
  52. $large_animalsQ=$db->query("SELECT id FROM users WHERE large_animals = ? ",array($largeanimals));
  53. $large_animals=$large_animalsQ->results();
  54. foreach ($large_animals as $c){
  55. if (!in_array($c, $matches))
  56. {
  57. array_push($matches,$c);
  58. }
  59. }
  60. }
  61.  
  62.  
  63. if($animal_habitat == 1){
  64. $animalhabitat = "animal habitat";
  65. $animal_habitatQ=$db->query("SELECT id FROM users WHERE animal_habitat = ? ",array($animalhabitat));
  66. $animal_habitat=$animal_habitatQ->results();
  67. foreach ($animal_habitat as $c){
  68. if (!in_array($c, $matches))
  69. {
  70. array_push($matches,$c);
  71. }
  72. }
  73. }
  74.  
  75. if($environment == 1){
  76. $environment = "environment";
  77. $environmentQ=$db->query("SELECT id FROM users WHERE environment = ? ",array($environment));
  78. $environment=$environmentQ->results();
  79. foreach ($environment as $c){
  80. if (!in_array($c, $matches))
  81. {
  82. array_push($matches,$c);
  83. }
  84. }
  85. }
  86.  
  87. if($habitat == 1){
  88. $habitat = "habitat";
  89. $habitatQ=$db->query("SELECT id FROM users WHERE habitat = ? ",array($habitat));
  90. $habitat=$habitatQ->results();
  91. foreach ($animal_habitat as $c){
  92. if (!in_array($c, $matches))
  93. {
  94. array_push($matches,$c);
  95. }
  96. }
  97. }
  98.  
  99. if($something == 1){
  100. $something = "something";
  101. $somethinQ=$db->query("SELECT id FROM users WHERE something = ? ",array($something));
  102. $something=$somethinQ->results();
  103. foreach ($something as $c){
  104. if (!in_array($c, $matches))
  105. {
  106. array_push($matches,$c);
  107. }
  108. }
  109. }
  110.  
  111. if($children == 1){
  112. $children = "children";
  113. $childrenQ=$db->query("SELECT id FROM users WHERE children = ? ",array($children));
  114. $children=$childrenQ->results();
  115. foreach ($children as $c){
  116. if (!in_array($c, $matches))
  117. {
  118. array_push($matches,$c);
  119. }
  120. }
  121. }
  122.  
  123. if($elderly == 1){
  124. $elderly = "elderly";
  125. $elderlyQ=$db->query("SELECT id FROM users WHERE elderly = ? ",array($elderly));
  126. $elderly=$elderlyQ->results();
  127. foreach ($elderly as $c){
  128. if (!in_array($c, $matches))
  129. {
  130. array_push($matches,$c);
  131. }
  132. }
  133. }
  134.  
  135. if($disabled == 1){
  136. $disabled = "disabled";
  137. $disabledQ=$db->query("SELECT id FROM users WHERE disabled = ? ",array($disabled));
  138. $disabled=$disabledQ->results();
  139. foreach ($disabled as $c){
  140. if (!in_array($c, $matches))
  141. {
  142. array_push($matches,$c);
  143. }
  144. }
  145. }
  146.  
  147. if($homeless == 1){
  148. $homeless = "homeless";
  149. $homelessQ=$db->query("SELECT id FROM users WHERE homeless = ? ",array($homeless));
  150. $homeless=$homelessQ->results();
  151. foreach ($homeless as $c){
  152. if (!in_array($c, $matches))
  153. {
  154. array_push($matches,$c);
  155. }
  156. }
  157. }
  158. //if you uncomment the line below, you can see your array
  159. dump($matches);
  160.  
  161. }
  162.  
  163. ?>
  164. <div id="page-wrapper">
  165. <div class="container">
  166. <div class="row">
  167. <div class="col-md-12">
  168.  
  169. <form class="" action="cbsearch2.php" method="post">
  170.  
  171. <div class="form-group">
  172.  
  173. <p><strong>Type of Project</strong> <i><small>Please check the boxes that represent your project the best (you can always update them later as well).</small></i></p>
  174.  
  175. <div class="col-xs-4">
  176. <div class="checkbox">
  177. <label><input type="checkbox" name="project" class="form-check" value="1">Projects</label>
  178. </div>
  179. <div class="checkbox">
  180. <label><input type="checkbox" name="volunteer" class="form-check" value="1">Volunteers</label>
  181. </div>
  182.  
  183. <div class="checkbox">
  184. <label><input type="checkbox" name="small_animals" class="form-check" value="1">Small animals</label>
  185. </div>
  186. <div class="checkbox">
  187. <label><input type="checkbox" name="large animals" class="form-check" value="1">Large animals</label>
  188. </div>
  189. <div class="checkbox">
  190. <label><input type="checkbox" name="animal habitat"class="form-check" value="1">Animal habitat</label>
  191. </div>
  192.  
  193.  
  194.  
  195. <div class="checkbox">
  196. <label><input type="checkbox" name="environment" class="form-check" value="1">Environment</label>
  197. </div>
  198. <div class="checkbox">
  199. <label><input type="checkbox" name="habitat" class="form-check" value="1">Habitat</label>
  200. </div>
  201. <div class="checkbox">
  202. <label><input type="checkbox" name="something" class="form-check" value="1">Something</label>
  203. </div>
  204.  
  205. <div class="checkbox">
  206. <label><input type="checkbox" name="children" class="form-check" value="1">Children</label>
  207. </div>
  208. <div class="checkbox">
  209. <label><input type="checkbox" name="elderly" class="form-check" value="1">Elderly</label>
  210. </div>
  211. <div class="checkbox">
  212. <label><input type="checkbox" name="disabled" class="form-check" value="1">Disabled</label>
  213. </div>
  214.  
  215. <div class="checkbox">
  216. <label><input type="checkbox" name="homeless" class="form-check" value="1">Homeless</label>
  217. </div>
  218.  
  219. <button class="submit btn btn-custom " type="submit" name='Submit' value='submit'>Search</button>
  220. </div>
  221.  
  222. </div><!-- /.from-group -->
  223. </form>
  224. </div><!-- /.col -->
  225. </div><!-- /.row -->
  226. <hr>
  227. <div class="row">
  228. <div class="col-md-12">
  229. <?php
  230. //See all the logic at the top of the page first!
  231. //Now you want go get your users list back. Let's just echo out the first/last name of each
  232. if(!empty($_POST)){
  233. echo "<strong>Here's what we found...</strong><br>";
  234. if(!empty($matches)){
  235. foreach ($matches as $m){
  236. $foundQ = $db->query("SELECT * FROM users WHERE id = ?",($m));
  237. $found = $foundQ->first();
  238. echo '<a href="users/profile.php?id='.$found->id.'"'.'>'.$found->fname.' '.$found->lname.'</a><br>';
  239. }
  240. }else{
  241. echo "Sorry. No users were found";
  242. }
  243. }
  244. ?>
  245.  
  246. </div><!-- /.col -->
  247. </div><!-- /.row -->
  248. </div> <!-- /container -->
  249. </div> <!-- /#page-wrapper -->
  250.  
  251.  
  252. <!-- footers -->
  253. <?php require_once $abs_us_root.$us_url_root.'users/includes/page_footer.php'; // the final html footer copyright row + the external js calls ?>
  254.  
  255. <!-- Place any per-page javascript here -->
  256.  
  257.  
  258. <?php require_once $abs_us_root.$us_url_root.'users/includes/html_footer.php'; // currently just the closing /body and /html ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement