Hi,
i am trying to build a search filter (like ebay site) using checkboxes. okay let me explain what i have done.
So, to get an idea of what type of thing i want please visite ebay site. i am also building ebay site as my project. visite this page please for better understanding https://www.ebay.com/sch/Other-Video-Games-Consoles/187/bn_1865232/i.html?_fsrp=1
i have build a web page completely look like this.
So, what i have done?
i have a search filter in which i have brand, plateform and model in which i get values from database.
Here is my code to get value from database same for plateform and model
<article class="search-item">
<h6 id="show">Brand</h6>
<ul>
<?php
if($cid)
{
$sql = "SELECT * FROM brands WHERE Cat_id = $cid";
$query = mysqli_query($connect,$sql);
$rs = mysqli_fetch_row($query);
if($rs == 0)
{
echo "";
}
else
{
while($brandrow = mysqli_fetch_array($query))
{
echo "<li><input type=\"checkbox\" name=\"brand\" value=\"".$brandrow['brand_id']."\" class=\"bcheckid check\" >".$brandrow['BrandName']."<li>";
}
}
}
?>
</ul>
</article>
i try using jquery ajax to search filter data on alerting a single value it works and show result but when i send this value using $.get method in jquery ajax i gives all html web page code, but i wants only the value. i am confused please help me. i only wants to value in $_GET method so please don’t use post method.
here is my jquery ajax code
$(document).ready(function(){
$(".check").click(function(){
var cid = <?php echo $cid = $_GET['cid'] ?>;
//alert(cid);
//for brand
var brand = new Array();
$("input[name=brand]:checked").each(function() {
brand.push($(this).val());
//alert(brand);
});
//for plateform
var plateform = new Array();
$("input[name=plateform]:checked").each(function() {
plateform.push($(this).val());
//alert(plateform);
});
//for model
var model = new Array();
$("input[name=model]:checked").each(function() {
model.push($(this).val());
//alert(model);
});
//$.get("item.php",{cid: cid,brand: brand,plateform: plateform,model: model
var formdata = $("#checkform").serialize();
$.ajax({
type:"get",
url:"result.php",
data:formdata//only input
});
});
});
Here is my item.php code where i get search filter result.
$cid = $_GET['cid'];
$plateform = $_GET['plateform'];
$brandid = $_GET['brand'];
$model_id = $_GET['model'];
if(!empty($cid))
{
$value = "Cat_id = $cid ";
}
else
{
$value = "";
}
$and = " AND ";
if(!empty($brandid))
{
$brand = $and."brand_id = ".implode(",", $brandid);
}
else
{
$brand ="";
}
if(!empty($plateform))
{
$plateform_id = $and."plateform_id IN (".implode(",", $plateform)."$plateform)";
}
else
{
$plateform_id ="";
}
if(!empty($model_id))
{
$model = $and."model_id = ".implode(",", $model_id);
}
if($cid == 3)
{
$model ="";
}
echo $prodsql = "SELECT * FROM products
INNER JOIN `condition` ON `products`.`condition_id` = `condition`.`condition_id`
WHERE $value $brand $plateform_id $model $pvalue
LIMIT $paginate->start, $paginate->limit;";
Again Please help me and thank you soooo much in advance. and sorry for my bad english.