I am using the code below to to pull information from my database, in the option menu, the data shows but for some reason the value is not being passed on to pull information using ajax. Please advise.
PHP:
<html>
<head>
<script type="text/javascript">
function showUser(str)
{
if (str=="")
{
document.getElementById("txtHint").innerHTML="";
return;
}
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("GET","ajax.php?q="+str,true);
xmlhttp.send();
}
</script>
</head>
<body>
<select onchange="display_data(this.value);">
<option>Select user</option>
<?php
include("config.php");
$query="SELECT p_name, full_name FROM users order by p_name asc";
$result=mysql_query($query);
while(list($p_name, $full_name)=mysql_fetch_row($result)) {
echo "<option value=\"".$p_name."\">".$full_name."</option>";
}
?>
</select>
<div id="txtHint"><div>
</body>
</html>
Ajax.php
<?php
$q=$_GET["q"];
include("config.php");
//Query
$sql = "select `full_name` from `users` where `p_name` = '$q'";
$query = mysql_query($sql) or die ("Error: ".mysql_error());
while ($row = mysql_fetch_array($query)){
$full_name = $row['Full_name'];
print $full_name
?>