<label>Category</label>
<select id="cate_id" name="cate_id" class="form-control">
<?php
$sql = "SELECT `id`,`name` FROM ".TBL_PRODUCT_CATEGORY." WHERE 1 ORDER BY `id` ASC;";
$query = mysqli_query($oconn, $sql);
while($row=mysqli_fetch_assoc($query)){
?>
<option value="<?=$row['id']?>"><?=$row['name']?></option>
<?php
}mysqli_free_result($query);
?>
</select>
<label>Brand</label>
<select id="b_id" name="b_id" class="form-control">
<?php
$sql = "SELECT `id`,`Brand_name` FROM ".TBL_BRAND." WHERE 1 ORDER BY `Brand_name` ASC;";
$query = mysqli_query($oconn, $sql);
while($row=mysqli_fetch_assoc($query)){
?>
<option value="<?=$row['id']?>"><?=$row['Brand_name']?></option>
<?php
}mysqli_free_result($query);
?>
</select>
ส่วนส่งค่าครับ
Code
var cate_id = $("#cate_id").val();
var b_id = $("#b_id").val();
$.get("<?=PATH_PANEL?>/product/list.php?cate_id="+cate_id+"&b_id="+b_id+"",function(result){
$("#list").html(result);
});
$("#cate_id ,#b_id").change(function(){
var cate_id = $(this).val();
var b_id = $(this).val();
$.get("<?=PATH_PANEL?>/product/list.php?cate_id="+cate_id+"&b_id="+b_id+"",function(result){
$("#list").html(result);
});
});
ส่วนแสดงผล list.php
$cate_id = trim($_GET['cate_id']);
$b_id = trim($_GET['b_id']);
$sql = "SELECT `id`,`name` FROM ".PRODUCT." WHERE 1 AND `cate_id`='".$cate_id."' AND `b_id`='".$b_id."' ORDER BY `id` DESC;";