this line in booktime.php does not work
if(isset($_POST['hair'])){
$hair=$_POST['hair'];
$query="SELECT first_name,last_name FROM employee_info e, employee_hair_service h WHERE e.e_id=h.e_id AND h.s_id=".$hair;
$query_result=mysqli_query($con,$query);
while($result_row=mysqli_fetch_array($query_result)){
echo " <option value='-Select-'>".$result_row[0].$result_row[2]."</option>";
}
}
i wanted to add options to dresser select box once the user chooses the 'hair' select box but it does not work
book.php
<script>
$(document).ready(function(){
$('.book_btn').click(function(){
var colIndex=$(this).index();
var day = $(this).closest("tr").find("td:eq(0)").text();
$.post("booktime.php",{
time: day,
}, function(data,status){
$("#book_time").html(data);
});
});
});
</script>
booktime.php
<?php
$con=mysqli_connect('localhost','root','','hair_salon');
if(isset($_POST['time'])){
$time=$_POST['time'];
echo "<form method='post'><table>
<tr>
<td>Time</td>
<td>".$time."</td>
</tr>
<tr>
<td>Service</td>
<td>
<select name='hair'>
<option selected='selected' value='-Select-'>-Select-</option>";
$con=mysqli_connect('localhost','root','','hair_salon');
$query = "SELECT s_id,s_name FROM hair_service";
$query_result=mysqli_query($con,$query);
while($result_row=mysqli_fetch_array($query_result)){
$s=$result_row[0];
$h=$result_row[1];
echo "<option value=".$s.">".$h."</option>";
}
echo "</select>
</td>
</tr>
<tr>
<td>HairDresser</td>
<td>
<select name='dresser'>;
<option selected='selected' value='-Select-'>-Select-</option>";
if(isset($_POST['hair'])){
$hair=$_POST['hair'];
$query="SELECT first_name,last_name FROM employee_info e, employee_hair_service h WHERE e.e_id=h.e_id AND h.s_id=".$hair;
$query_result=mysqli_query($con,$query);
while($result_row=mysqli_fetch_array($query_result)){
echo " <option value='-Select-'>".$result_row[0].$result_row[2]."</option>";
}
}
echo "</select>
</td>
</tr>
</table></form>";
}
?>