Guest User

Untitled

a guest
Jan 18th, 2017
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 8.05 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.     $small_animals = Input::get('small_animals');
  9.     $large_animals = Input::get('large_animals');
  10.     $animal_habitat = Input::get('animal_habitat');
  11.     $environment = Input::get('environment');
  12.     $habitat = Input::get('habitat');
  13.     $something = Input::get('something');
  14.     $children = Input::get('children');
  15.     $elderly = Input::get('elderly');
  16.     $disabled = Input::get('disabled');
  17.     $homeless = Input::get('homeless');
  18.  
  19.     $matches = [];
  20.  
  21.     if($small_animals == 1){
  22.         $smallanimals = "small animals";
  23.         $small_animalsQ=$db->query("SELECT id FROM users WHERE small_animals = ? ",array($smallanimals));
  24.         $small_animals=$small_animalsQ->results();
  25.         foreach ($small_animals as $c){
  26.            array_push($matches,$c);
  27.         }
  28.     }
  29.  
  30.     if($large_animals == 1){
  31.         $largeanimals = "large animals";
  32.         $large_animalsQ=$db->query("SELECT id FROM users WHERE large_animals = ? ",array($largeanimals));
  33.         $large_animals=$large_animalsQ->results();
  34.         foreach ($large_animals as $c){
  35.            if (!in_array($c, $matches))
  36.            {
  37.            array_push($matches,$c);
  38.            }
  39.         }
  40.     }
  41.    
  42.    
  43.     if($animal_habitat == 1){
  44.         $animalhabitat = "animal habitat";
  45.         $animal_habitatQ=$db->query("SELECT id FROM users WHERE animal_habitat = ? ",array($animalhabitat));
  46.         $animal_habitat=$animal_habitatQ->results();
  47.         foreach ($animal_habitat as $c){
  48.             if (!in_array($c, $matches))
  49.             {
  50.             array_push($matches,$c);
  51.             }
  52.         }
  53.     }
  54.    
  55.     if($environment == 1){
  56.         $environment = "environment";
  57.         $environmentQ=$db->query("SELECT id FROM users WHERE environment = ? ",array($environment));
  58.         $environment=$environmentQ->results();
  59.         foreach ($environment as $c){
  60.             if (!in_array($c, $matches))
  61.             {
  62.             array_push($matches,$c);
  63.             }
  64.         }
  65.     }
  66.    
  67.     if($habitat == 1){
  68.         $habitat = "habitat";
  69.         $habitatQ=$db->query("SELECT id FROM users WHERE habitat = ? ",array($habitat));
  70.         $habitat=$habitatQ->results();
  71.         foreach ($animal_habitat as $c){
  72.            if (!in_array($c, $matches))
  73.            {
  74.            array_push($matches,$c);
  75.            }
  76.         }
  77.     }
  78.    
  79.     if($something == 1){
  80.         $something = "something";
  81.         $somethinQ=$db->query("SELECT id FROM users WHERE something = ? ",array($something));
  82.         $something=$somethinQ->results();
  83.         foreach ($something as $c){
  84.             if (!in_array($c, $matches))
  85.             {
  86.             array_push($matches,$c);
  87.             }
  88.         }
  89.     }
  90.    
  91.     if($children == 1){
  92.         $children = "children";
  93.         $childrenQ=$db->query("SELECT id FROM users WHERE children = ? ",array($children));
  94.         $children=$childrenQ->results();
  95.         foreach ($children as $c){
  96.             if (!in_array($c, $matches))
  97.             {
  98.             array_push($matches,$c);
  99.             }
  100.         }
  101.     }
  102.    
  103.     if($elderly == 1){
  104.         $elderly = "elderly";
  105.         $elderlyQ=$db->query("SELECT id FROM users WHERE elderly = ? ",array($elderly));
  106.         $elderly=$elderlyQ->results();
  107.         foreach ($elderly as $c){
  108.             if (!in_array($c, $matches))
  109.             {
  110.             array_push($matches,$c);
  111.             }
  112.         }
  113.     }
  114.    
  115.     if($disabled == 1){
  116.         $disabled = "disabled";
  117.         $disabledQ=$db->query("SELECT id FROM users WHERE disabled = ? ",array($disabled));
  118.         $disabled=$disabledQ->results();
  119.         foreach ($disabled as $c){
  120.             if (!in_array($c, $matches))
  121.             {
  122.             array_push($matches,$c);
  123.             }
  124.         }
  125.     }
  126.    
  127.     if($homeless == 1){
  128.         $homeless = "homeless";
  129.         $homelessQ=$db->query("SELECT id FROM users WHERE homeless = ? ",array($homeless));
  130.         $homeless=$homelessQ->results();
  131.         foreach ($homeless as $c){
  132.             if (!in_array($c, $matches))
  133.             {
  134.             array_push($matches,$c);
  135.             }
  136.         }
  137.     }
  138.     //if you uncomment the line below, you can see your array
  139.     //dump($matches);
  140.  
  141. }
  142.  
  143. ?>
  144.  
  145. <div id="page-wrapper">
  146.     <div class="container">
  147.         <div class="row">
  148.             <div class="col-xs-12">
  149.                 <div class="jumbotron">
  150.                     <h1>Welcome to UserSpice</h1>
  151.                 </div>
  152.             </div>
  153.         </div>
  154.  
  155.         <div class="row">
  156.             <div class="col-md-12">
  157.  
  158.                 <form class="" action="cbsearch.php" method="post">
  159.                     <div class="col-md-2">
  160.                         <label><input type="checkbox" name="small animals" class="form-control" value="1">Small animals</label>
  161.                     </div>
  162.                     <div class="col-md-2">
  163.                         <label><input type="checkbox" name="large animals" class="form-control" value="1">Large animals</label>
  164.                     </div>
  165.                     <div class="col-md-2">
  166.                         <label><input type="checkbox" name="animal habitat" class="form-control" value="1">Animal habitat</label>
  167.                     </div>
  168.                     <div class="col-md-2">
  169.                         <label><input type="checkbox" name="environment" class="form-control" value="1">Environment</label>
  170.                     </div>
  171.                     <div class="col-md-2">
  172.                         <label><input type="checkbox" name="habitat" class="form-control" value="1">Habitat</label>
  173.                     </div>
  174.                     <div class="col-md-2">
  175.                         <label><input type="checkbox" name="something" class="form-control" value="1">Something</label>
  176.                     </div>
  177.                     <div class="col-md-2">
  178.                         <label><input type="checkbox" name="children" class="form-control" value="1">Children</label>
  179.                     </div>
  180.                     <div class="col-md-2">
  181.                         <label><input type="checkbox" name="elderly" class="form-control" value="1">Elderly</label>
  182.                     </div>
  183.                     <div class="col-md-2">
  184.                         <label><input type="checkbox" name="disabled" class="form-control" value="1">Disabled</label>
  185.                     </div>
  186.                     <div class="col-md-2">
  187.                         <label><input type="checkbox" name="homeless" class="form-control" value="1">Homeless</label>
  188.                     </div>
  189.                     <input class='btn btn-danger' type='submit' name='Submit' value='submit' />
  190.                 </form>
  191.                 <?php
  192.                 //See all the logic at the top of the page first!
  193.                 //Now you want go get your users list back.  Let's just echo out the first/last name of each
  194.                 if(!empty($_POST)){
  195.                     echo "<strong>Here's what we found...</strong><br>";
  196.                     if(!empty($matches)){
  197.                         foreach ($matches as $m){
  198.                             $foundQ = $db->query("SELECT * FROM users WHERE id = ?",($m));
  199.                             $found = $foundQ->first();
  200.                             echo $found->fname." ".$found->lname."<br>";
  201.                         }
  202.                     }else{
  203.                         echo "Sorry. No users were found";
  204.                     }
  205.                 }
  206.                 ?>
  207.  
  208.             </div><!-- /.col -->
  209.         </div><!-- /.row -->
  210.  
  211.     </div> <!-- /container -->
  212.  
  213. </div> <!-- /#page-wrapper -->
  214.  
  215. <!-- footers -->
  216. <?php require_once $abs_us_root.$us_url_root.'users/includes/page_footer.php'; // the final html footer copyright row + the external js calls ?>
  217.  
  218. <!-- Place any per-page javascript here -->
  219.  
  220.  
  221. <?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