I have a page2 that is linked from page1.page1 sends a unique job id to page2.page2 has ajax code as shown below.In this page2,i have a select that takes in the number of applicants to be called for an interview.it fetches this number from page3 according to the number of points achieved by each applicant.How will I fetch data for applicants according to the passed job id?I think my problem is passing parameters in ajax.Any help please? thus is my code but isnt working.I get error in page2,An uknown index jobid.
<?php $getid =$_GET['jobid'];?>
<html>
<head>
<link href="css/bootstrap.min.css" rel="stylesheet">
<script>
function showSuccess(str,$getid) {
if (str == "") {
document.getElementById("txtHint").innerHTML = "";
return;
} else {
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else {
// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange =
function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById("txtHint").innerHTML = xmlhttp.responseText;
}
}
xmlhttp.open("POST","interview.php?q="+str);
xmlhttp.send();
}
}
</script>
</head>
<body>
<?php
echo $getid;
?>
<div class="col-md-4 col-md-offset-4">
<form>
<?php
include('includes/conn.php');
$row="SELECT * FROM jobs";
$query=mysqli_query($conn,$row) or die(mysqli_error($conn));
while($row=mysqli_fetch_array($query)){
$ref=$row['id'];
}
echo '<select name="names" onchange="showSuccess(this.value'.$getid.')" class="form-control">
<option value="">Select a person:</option>
<option value="5">5</option>
<option value="0">0</option>
<option value="10">10</option>
<option value="15">15</option>
<option value="20">20</option>
<option value="25">25</option>
<option value="30">30</option>
<option value="35">35</option>
<option value="40">40</option>
<option value="45">45</option>
<option value="50">50</option>
<option value="55">55</option>
<option value="60">60</option>
<option value="65">65</option>
<option value="70">70</option>
<option value="75">75</option>
<option value="80">80</option>
<option value="85">85</option>
<option value="90">90</option>
<option value="95">95</option>
<option value="100">100</option>
</select>';
?>
<!--<input type="text" class="form-control" name="number" placeholder='Enter the no of candidates' required>-->
</form>
</div>
<br>
<div id="txtHint" class="col-md-4 col-md-offset-4"><b>The candidates</b></div>
</body>
</html>
<?php $q = intval($_GET['q']);
?>
<?php $getid = intval($_POST['$getid']);?>
<?php
include('includes/conn.php');
$row="SELECT idNo,id,name,jobTitle,SUM(points) AS total FROM shortlist WHERE job='$getid' GROUP BY id ORDER BY total DESC LIMIT $q";
$query=mysqli_query($conn,$row) or die(mysqli_error($conn));
while($row=mysqli_fetch_array($query))
{
echo $row['name'];
}
mysqli_close($conn);
?>
You are sending the value in POST
data
xmlhttp.open("POST","interview.php?q="+str);
But in the 3rd file you are using,
<?php $getid = intval($_POST['$getid']);
?>
You are not sending $getid
in the POST/GET parameters.