I have a column named weight in my table accounts. i need to fetch the values from this column like,
when the user clicks weight from 40 - 100, It need to display all the persons with weight in between 40 and 100.
This is my html code,
<div class="float-right span35">
<form class="list-wrapper search-form" method="get" action="/index.php">
<div class="list-header">
Talent Search
</div>
<h4 style="margin-left: 10px; color: gray;">Weight</h4>
<fieldset id="weight">
<input type="checkbox" name="weight" value="1" />Below 40<br>
<input type="checkbox" name="weight" value="2" />40-70<br>
<input type="checkbox" name="weight" value="3" />70-100<br>
<input type="checkbox" name="weight" value="4" />Above 100<br>
</fieldset>
<br/>
<input style="margin-left: 10px" type="submit" name="submit" value="search"/><br><br>
<input type="hidden" name="tab1" value="search">
</form>
</div>
This is my php code,
if(isset($_GET['submit'])){
$weight = ($_GET['weight'])? $escapeObj->stringEscape($_GET['weight']): NULL;
$sql = "SELECT id FROM `".DB_ACCOUNTS."` WHERE `id` IS NOT NULL ";
if(is_numeric($weight) && $weight != NULL){
$sql .= "AND `weight` IN (".$weight.")";
$is_weight = true;
}
$sql .= " ORDER BY `id` ASC";
}
if($is_weight){
$themeData['weight_'.$weight] = 'checked';
}
$query = $conn->query($sql);
if($query->num_rows > 0){
while($fetch = $query->fetch_array(MYSQLI_ASSOC)){
$get[] = $fetch['id'];
}
$i = 0;
$listResults = '';
$themeData['page_title'] = "Advanced Search - ".$lang['search_result_header_label'];
foreach($get as $row){
$timelineObj = new \SocialKit\User();
$timelineObj->setId($row);
$timeline = $timelineObj->getRows();
$themeData['list_search_id'] = $timeline['id'];
$themeData['list_search_url'] = $timeline['url'];
$themeData['list_search_username'] = $timeline['username'];
$themeData['list_search_name'] = $timeline['name'];
$themeData['list_search_thumbnail_url'] = $timeline['thumbnail_url'];
$themeData['list_search_button'] = $timelineObj->getFollowButton();
$listResults .= \SocialKit\UI::view('search/list-each');
$i++;
}
$themeData['list_search_results'] = $listResults;
}
}
This code is almost working for an single weight from table. But I need to create a range in between the checkbox values as i mentioned in the code. Do i need to update the code.
Aucun commentaire:
Enregistrer un commentaire