So I am trying to pass back a couple values to a PHP page like this.
function showAccountInfo(obj){
var value = obj.value;
var content = obj.querySelector("option:checked").textContent;
alert("value: " + value + " content: " + content);
if(obj == ""){
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("facilities").innerHTML = xmlhttp.responseText;
}
}
xmlhttp.open("GET","getinfo.php?=q"+value+"&c="+content, true);
xmlhttp.send();
}
}
When the alert goes off it shows me the correct values for each variable. However when I pass off that value to getinfo.php and use the variable value to complete a query and echo it out to the page it shows me it as empty.
$q = ($_GET['q']);
$sql = "SELECT *, account.account_name FROM facility "
. "INNER JOIN account ON account.account_id = facility.account_id "
. "WHERE facility.account_id = '".$q."'";
echo $sql;
Result: SELECT *, account.account_name FROM facility INNER JOIN account ON account.account_id = facility.account_id WHERE facility.account_id = ''
I had everything functioning properly prior my previous question.