-
Notifications
You must be signed in to change notification settings - Fork 0
/
locationsearch.php
148 lines (138 loc) · 6.57 KB
/
locationsearch.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<?php
ob_start();
require_once ("configuration/db_config.php");
require_once ("controllers/categoryclass.php");
require_once ("controllers/searchcategories.php");
$title ="Categories and Location";
$description ='';
$keyWords ='';
include ("includes/head.php")
?>
<div class="wrapper">
<?php include ("includes/navbar.php");
$price_sort = ((isset($_REQUEST['price_sort']))?checkInput($_REQUEST['price_sort']):"");
$min_price = ((isset($_REQUEST['min_price']))?checkInput($_REQUEST['min_price']):"");
$max_price = ((isset($_REQUEST['max_price']))?checkInput($_REQUEST['max_price']):"");
$purpose = ((isset($_REQUEST['purpose']))?checkInput($_REQUEST['purpose']):"");
$region = ((isset($_REQUEST['region']))?checkInput($_REQUEST['region']):"");
$category = ((isset($_REQUEST['cat']))?checkInput($_REQUEST['cat']):"");
if($_SERVER["REQUEST_METHOD"]=="GET"){
$searchKeywords = checkInput($_GET['search']);
$location2 = checkInput((int)$_GET['region']);
$locationSearch = new SearchCategory();
require_once ('pagination/pagination.php');
$adsNotPaginated = $locationSearch->searchByLocation($searchKeywords,$location2);
$row_count = count($adsNotPaginated);
$data['total_records'] =$row_count;
$data['records_per_page'] = 3;
$data['pagination_url']= "locationsearch.php?search=".$searchKeywords."®ion=".$location2;
$page = new pagination;
// $page->pagination_display($data);
$start_rocord = $page->start_record($data);
$records_per_page = $data['records_per_page'];
$ads = $locationSearch->paginateSearchByLocation($searchKeywords,$location2, $start_rocord,$records_per_page);
if($ads){
?>
<h6> <?php echo $row_count ?> found
<span id="advanced-search">click to simplify the search</span> </h6>
<section class="product-display">
<!-- Search form -->
<div class="search-form">
<p>Filter By:</p>
<form action="filteredresult.php" method ="post">
<input type="hidden" name ="region" value ="<?php echo $location2?>">
<input type="hidden" name = "price_sort" value ="0">
<div class="form-group">
<label for="price_sort" class="form-control">Price Level</label>
<input type="radio" name ="price_sort"
value = "low" <?php echo (($price_sort =='low')?"checked":"") ?>> Low To High <br/>
<input type="radio" name ="price_sort"
value = "high" <?php echo (($price_sort =='high')?"checked":"") ?>> High To Low
</div>
<div class="form-group">
<label for="price_sort">Price Range</label> <br/>
<input type="text" name ="min_price"
value="<?php echo $min_price ?>" placeholder = "enter min ₦"> <br/>
To <br/>
<input type="text" name ="max_price"
value="<?php echo $max_price ?>" placeholder = "enter max ₦">
</div>
<div class="form-group">
<label for="purpose" class="form-control">Purpose</label>
<select name="purpose" id="">
<option value=""> buy or rent? Select an option</option>
<option value="sale" <?php echo (($purpose == "sale")?"selected": ""); ?>>Property for Sales</option>
<option value="rent" <?php echo (($purpose == "rent")?"selected": ""); ?>>Property for Rent</option>
</select>
</div>
<div class="form-group">
<label for="cat" class="form-control">Category</label>
<select name="cat" id="cat" >
<option value="">--Select a category--</option>
<?php
$catobj = new Category();
$categories = $catobj->getCategory();
foreach($categories as $category){
?>
<option value="<?php echo $category['cat_id'] ?>"
<?php
if(isset($cat_id) && $cat_id == $category['cat_id']){
echo "selected";
}
?>
>
<?php echo $category['name'] ?></option>
<?php } ?>
</select> <br/> <br/>
<span>Apply Search</span> <button> <i class="fas fa-search fa-lg"></i></button>
</div>
</form>
</div>
<!--Details -->
<div class="searched-result">
<?php
foreach($ads as $ad){
$adsImages = explode(',', $ad['images']);
?>
<div class="info-images">
<div class="image-div">
<a href="singleproduct/<?php echo $ad['id'] ?>/<?php echo $ad['category_id'] ?>/<?php echo $ad['user_id']; ?>">
<img src="<?php echo $adsImages[0] ?>" class="adjust-image" alt="Port folio logos">
</a>
</div>
<div class="info-div">
<p class="product-view"><?php echo nl2br($ad['title']) ?></p>
<span class="product-view">For:<b class="product-view-purpose">
<?php echo $ad['purpose'] ?></b></span> <br>
<span class="product-view">Location: <?php echo $ad['region_name'] ?></span>,
<span class="product-view"><?php echo $ad['state_name'] ?> State </span> <br>
<span class="product-view">Price: ₦ <b class="product-view-price">
<?php echo number_format($ad['price'] )?></b></span> <br>
<span class="product-view">
<a href="singleproduct/<?php echo $ad['id'] ?>/<?php echo $ad['category_id'] ?>/<?php echo $ad['user_id'] ?>">View details</a>
</span>
</div>
</div>
<?php
}
}else{
echo "<p class='text-center'>No
record is found for ('".$searchKeywords."') in '".$location2."'
Region. Please use a
more precise key words or better still change the city</p>";
}
}
?>
</div>
</section>
<!-- for the pagination -->
<section class="pagination">
<?php $page->pagination_display($data); ?>
</section>
<span id="timer"></span>
<?php include ("includes/footer.php"); ?>
<script src="js/popper.min.js"></script>
<script src="js/jquery.js"></script>
<script src="js/mainnavbarjs.js"></script>
<script src="js/main.js"></script>
<script src="js/categorysearch.js"></script>