Advertisement
Guest User

Untitled

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