<?php
function Display_all_user()
{
$sql = "SELECT DISTINCT(tu.`user_name`), tu.`deleted`, tuc.`seller_id`, tu.`email_id` FROM `tbl_user` tu, `tbl_used_car` tuc
WHERE tu.`email_id`=tuc.`seller_id` AND tu.`deleted`='0'";
$result = $GLOBALS['con2']->query($sql);
if ($result->num_rows > 0)
{
echo "<option value='0'>Select Dealer</option>";
while($row = $result->fetch_assoc())
{
echo "<option value='$row[email_id]'>$row[user_name]</option>";
}
}
}
?>
<td style="padding:10px;">
<select id="sel_dealer" class="form-control" onchange="select_dealer(this)">
<?php Display_all_user(); ?>
</select>
</td>
<td style="padding:10px;" id="dis_brand"></td>
-------ajax-------
function select_dealer(ths){
cnt=0;
var dealer = $(ths).val();
$.ajax({
url:"MainbankAdministration/backend_code/ajax/manage_old_car_ajax.php",
type:"post",
data:{"filter":true,"sel_user":dealer},
success:function(result){
$("#dis_brand").html(result);
if(dealer==0){
$("#dis_brand").html("");
$("#dis_model").html("");
}
}
});
--------------ajax.php---------------------
<?php
if(isset($_POST['filter'])){
if(isset($_POST['sel_user']))
{
$sql = "SELECT DISTINCT(tcb.`brand_name`), tcb.`brand_id` FROM `tbl_used_car` tu, `tbl_car_version` tcv, `tbl_car_model` tcm, `tbl_car_brand` tcb
WHERE tu.`version_id`=tcv.`version_id`
AND tcm.`model_id`=tcv.`model_id`
AND tcm.`brand_id`=tcb.`brand_id`
AND tu.`seller_id`='$_POST[sel_user]'";
$result = $GLOBALS['con2']->query($sql);
if ($result->num_rows > 0)
{
echo "<select class='form-control' onchange='sel_brand(this);' name='sel_brand' id='sel_brand'>
<option value='0'>Select Brand</option>";
while($row = $result->fetch_assoc())
{
echo "<option value='$row[brand_id]'>$row[brand_name]</option>";
}
echo "</select>";
}
}
}
?>
我想使用jquery旋钮,我会显示我的猜测数,从6到0开始。
我该怎么做才能做到这一点?任何参考都会有所帮助。