I've got this ajax code that passes one variable for a mysql query. I need to pass an other variable. I already got the variable, but i don't know how to add it to the existing code.
this is the code
function Docent(){
var opleidingid = $('#opleidingddl').val();
var datum = $('#datumddl :selected').text();
$('#docentddl').html();
$('#docentddl').html("<option>Loading.....</option>");
$.ajax({
type:"POST",
url:"Docent.php"
data :
{
'opleidingid': opleidingid,
'datum' : datum
},
success: function(data){
$('#docentddl').html();
$('#docentddl').html("<option value='0'>Selecteer docent</option>");
$.each(data,function(i,item){
$('#docentddl').append('<option value="'+ data[i].Opleiding_ID +'">'+ data[i].Docent+'</option>');
$('#docentddl').selectpicker('refresh');
});
},
complete: function(){
}
});
}
PHP
<?php
include ('config.php');
$opleidingid = $_POST['opleidingid'];
$datum = $_POST['datum'];
$sql=mysql_query("SELECT * FROM Docent_relatie WHERE Opleiding_ID = 'opleidingid'");
if(mysql_num_rows($sql)){
$data = array();
while($row=mysql_fetch_array($sql)){
$data[] = array(
'Opleiding_ID' => $row['Opleiding_ID'],
'Docent' => $row['Docent'],
'OpleidingDatum' => $row['OpleidingDatum']
);
}
header('Content-type: application/json');
echo json_encode($data);
}
?>