I have 3 dropdown list (semester,section and subject) if I choose a semester it will populate section. Now if I choose a section it will populate subject but it does not read semester. it just display all the available subjects of the chosen section not considering what semester it is.
function showSEMESTER(semester)
{
var item = semester;
var dataString = 'semester='+ semester;
$.ajax
({
type: "POST",
url: "class-select.php",
data: dataString,
cache: false,
success: function(html)
{
$("#class_id").html(html);
}
});
}
function showSubject(section)
{
var item = section;
var dataString = 'code='+ item;
$.ajax
({
type: "POST",
url: "subject-select.php",
data: dataString,
cache: false,
success: function(html)
{
$("#subject_id").html(html);
}
});
}
here is the sql for subject select
$query = "select * from subject where class_id = '$_POST[code]' and semester_id='$_POST[semester]' ";
this does not return any $_post[semester]
change
$query = "select * from subject where class_id = '$_POST[code]' and semester_id='$_POST[semester]' ";
to
$query = 'select * from subject where class_id = "'.$_POST['code'].'" and semester_id="'.$_POST['semester'].'"';
$_POST is an array with string indexes. You lack quotes ""
or ''
for the $_POST indexes.