使用php&;从Cat显示子类别;AJAX
我需要通过使用ajax和php显示选择cat的子cat 先选猫使用php&;从Cat显示子类别;AJAX,php,ajax,Php,Ajax,我需要通过使用ajax和php显示选择cat的子cat 先选猫 <select style="font-family:'Droid Arabic Kufi', serif" id='dep' name="dep_id" class="form-control m-bot15"> <option selected disabled hidden value=''></option>
<select style="font-family:'Droid Arabic Kufi', serif" id='dep' name="dep_id" class="form-control m-bot15">
<option selected disabled hidden value=''></option>
<?php
$e = mysql_query("select * from dep");
while ($row = mysql_fetch_array($e)) {
extract($row);
echo"<option value='$id'>$dep_name</option>";
}
?>
</select>
国际单项体育联合会(国际单项体育联合会){
$q=$_POST['q']
if ($q == '1') {
$id = $_POST['id'];
$arr = array(array(array()));
$e = mysql_query("select * from sub where dep='" . $id . "'") or die('sql error');
$i = 0;
while ($row = mysql_fetch_array($e)) {
$arr[0][$i] = $row['id'];
$arr[1][$i++] = $row['sub_name'];
}
$json = json_encode($arr);
print_r($json);
}
它不起作用我需要知道为什么
include("config.php");
if ($q == '1') {
$id = $_POST['id'];
$arr = array(array(array()));
$e = mysql_query("select * from sub where dep='" . $id . "'") or die('sql error');
$i = 0;
while ($row = mysql_fetch_array($e)) {
$arr[0][$i] = $row['id'];
$arr[1][$i++] = $row['sub_name'];
}
$json = json_encode($arr);
print_r($json);
}