Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once 'users/init.php';
- require_once $abs_us_root.$us_url_root.'users/includes/header.php';
- require_once $abs_us_root.$us_url_root.'users/includes/navigation.php';
- ?>
- <?php
- if(!empty($_POST)){
- $project = Input::get('project');
- $volunteer = Input::get('volunteer');
- $small_animals = Input::get('small_animals');
- $large_animals = Input::get('large_animals');
- $animal_habitat = Input::get('animal_habitat');
- $environment = Input::get('environment');
- $habitat = Input::get('habitat');
- $something = Input::get('something');
- $children = Input::get('children');
- $elderly = Input::get('elderly');
- $disabled = Input::get('disabled');
- $homeless = Input::get('homeless');
- $matches = [];
- if($project == 1){ //it's getting this from the value of the checkbox
- $project = '1';
- $projectQ=$db->query("SELECT id FROM users WHERE project = ? ",array($project));
- $project=$projectQ->results();
- foreach ($project as $c){
- array_push($matches,$c);
- }
- }
- if($volunteer == 1){
- $volunteer = '1';
- $volunteerQ=$db->query("SELECT id FROM users WHERE volunteer = ? ",array($volunteer));
- $volunteer=$volunteerQ->results();
- foreach ($volunteer as $c){
- array_push($matches,$c);
- }
- }
- if($small_animals == 1){
- $smallanimals = "small animals";
- $small_animalsQ=$db->query("SELECT id FROM users WHERE small_animals = ? ",array($smallanimals));
- $small_animals=$small_animalsQ->results();
- foreach ($small_animals as $c){
- array_push($matches,$c);
- }
- }
- if($large_animals == 1){
- $largeanimals = "large animals";
- $large_animalsQ=$db->query("SELECT id FROM users WHERE large_animals = ? ",array($largeanimals));
- $large_animals=$large_animalsQ->results();
- foreach ($large_animals as $c){
- if (!in_array($c, $matches))
- {
- array_push($matches,$c);
- }
- }
- }
- if($animal_habitat == 1){
- $animalhabitat = "animal habitat";
- $animal_habitatQ=$db->query("SELECT id FROM users WHERE animal_habitat = ? ",array($animalhabitat));
- $animal_habitat=$animal_habitatQ->results();
- foreach ($animal_habitat as $c){
- if (!in_array($c, $matches))
- {
- array_push($matches,$c);
- }
- }
- }
- if($environment == 1){
- $environment = "environment";
- $environmentQ=$db->query("SELECT id FROM users WHERE environment = ? ",array($environment));
- $environment=$environmentQ->results();
- foreach ($environment as $c){
- if (!in_array($c, $matches))
- {
- array_push($matches,$c);
- }
- }
- }
- if($habitat == 1){
- $habitat = "habitat";
- $habitatQ=$db->query("SELECT id FROM users WHERE habitat = ? ",array($habitat));
- $habitat=$habitatQ->results();
- foreach ($animal_habitat as $c){
- if (!in_array($c, $matches))
- {
- array_push($matches,$c);
- }
- }
- }
- if($something == 1){
- $something = "something";
- $somethinQ=$db->query("SELECT id FROM users WHERE something = ? ",array($something));
- $something=$somethinQ->results();
- foreach ($something as $c){
- if (!in_array($c, $matches))
- {
- array_push($matches,$c);
- }
- }
- }
- if($children == 1){
- $children = "children";
- $childrenQ=$db->query("SELECT id FROM users WHERE children = ? ",array($children));
- $children=$childrenQ->results();
- foreach ($children as $c){
- if (!in_array($c, $matches))
- {
- array_push($matches,$c);
- }
- }
- }
- if($elderly == 1){
- $elderly = "elderly";
- $elderlyQ=$db->query("SELECT id FROM users WHERE elderly = ? ",array($elderly));
- $elderly=$elderlyQ->results();
- foreach ($elderly as $c){
- if (!in_array($c, $matches))
- {
- array_push($matches,$c);
- }
- }
- }
- if($disabled == 1){
- $disabled = "disabled";
- $disabledQ=$db->query("SELECT id FROM users WHERE disabled = ? ",array($disabled));
- $disabled=$disabledQ->results();
- foreach ($disabled as $c){
- if (!in_array($c, $matches))
- {
- array_push($matches,$c);
- }
- }
- }
- if($homeless == 1){
- $homeless = "homeless";
- $homelessQ=$db->query("SELECT id FROM users WHERE homeless = ? ",array($homeless));
- $homeless=$homelessQ->results();
- foreach ($homeless as $c){
- if (!in_array($c, $matches))
- {
- array_push($matches,$c);
- }
- }
- }
- //if you uncomment the line below, you can see your array
- dump($matches);
- }
- ?>
- <div id="page-wrapper">
- <div class="container">
- <div class="row">
- <div class="col-md-12">
- <form class="" action="cbsearch2.php" method="post">
- <div class="form-group">
- <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>
- <div class="col-xs-4">
- <div class="checkbox">
- <label><input type="checkbox" name="project" class="form-check" value="1">Projects</label>
- </div>
- <div class="checkbox">
- <label><input type="checkbox" name="volunteer" class="form-check" value="1">Volunteers</label>
- </div>
- <div class="checkbox">
- <label><input type="checkbox" name="small_animals" class="form-check" value="1">Small animals</label>
- </div>
- <div class="checkbox">
- <label><input type="checkbox" name="large animals" class="form-check" value="1">Large animals</label>
- </div>
- <div class="checkbox">
- <label><input type="checkbox" name="animal habitat"class="form-check" value="1">Animal habitat</label>
- </div>
- <div class="checkbox">
- <label><input type="checkbox" name="environment" class="form-check" value="1">Environment</label>
- </div>
- <div class="checkbox">
- <label><input type="checkbox" name="habitat" class="form-check" value="1">Habitat</label>
- </div>
- <div class="checkbox">
- <label><input type="checkbox" name="something" class="form-check" value="1">Something</label>
- </div>
- <div class="checkbox">
- <label><input type="checkbox" name="children" class="form-check" value="1">Children</label>
- </div>
- <div class="checkbox">
- <label><input type="checkbox" name="elderly" class="form-check" value="1">Elderly</label>
- </div>
- <div class="checkbox">
- <label><input type="checkbox" name="disabled" class="form-check" value="1">Disabled</label>
- </div>
- <div class="checkbox">
- <label><input type="checkbox" name="homeless" class="form-check" value="1">Homeless</label>
- </div>
- <button class="submit btn btn-custom " type="submit" name='Submit' value='submit'>Search</button>
- </div>
- </div><!-- /.from-group -->
- </form>
- </div><!-- /.col -->
- </div><!-- /.row -->
- <hr>
- <div class="row">
- <div class="col-md-12">
- <?php
- //See all the logic at the top of the page first!
- //Now you want go get your users list back. Let's just echo out the first/last name of each
- if(!empty($_POST)){
- echo "<strong>Here's what we found...</strong><br>";
- if(!empty($matches)){
- foreach ($matches as $m){
- $foundQ = $db->query("SELECT * FROM users WHERE id = ?",($m));
- $found = $foundQ->first();
- echo '<a href="users/profile.php?id='.$found->id.'"'.'>'.$found->fname.' '.$found->lname.'</a><br>';
- }
- }else{
- echo "Sorry. No users were found";
- }
- }
- ?>
- </div><!-- /.col -->
- </div><!-- /.row -->
- </div> <!-- /container -->
- </div> <!-- /#page-wrapper -->
- <!-- footers -->
- <?php require_once $abs_us_root.$us_url_root.'users/includes/page_footer.php'; // the final html footer copyright row + the external js calls ?>
- <!-- Place any per-page javascript here -->
- <?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