0

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]

1
  • 1
    I'm interested in taking a class on '; DROP TABLE subject; --. Can you tell me when the next classes are, please? Commented Sep 19, 2013 at 14:40

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.