PHP, AJAX Auto fill input fields from HTML select?


I hv been attempting for a while to search a right method of pulling info from a DB based on the initial text
selected on a html drop down menu.
Here is my code snippet:




<?php
$host = "";
$username = "";
$password = "";
$database = "";
mysql_connect($host $username $password);
mysql_select_db($database);
?>






database ID


Population


Unique ID


Person info will be listed here.




test.js having:
function showUser(str)
{
if (str=="")
{
document.getElementById("GetInformation").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{// code snippet for IE7+ Firefox Chrome Opera Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code snippet for IE6 IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("GetInformation").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET" "getuser.php?q="+str true);
xmlhttp.send();
}

Get member having:
<?php
$q=$_GET"q";
$con = mysql_connect('' '' '');
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("DropDown" $con);
$sql="SELECT * FROM population WHERE uid = '".$q."'";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
{
$ID = $row'ID';
$Pop = $row'Pop';
$UID = $row'uid';
?>

<?php }
mysql_close($con);
?>




Get Source Code

  Views 66   Posted on : Tuesday, March 12, 2013 10:15:42 AM
Related Tags:




Replies on "PHP, AJAX Auto fill input fields from HTML select?" :

Nobody has replied on this post , be first to post answer.


Post Your Answer/Comment:

Please Login first to post Reply !


Note: Please Put Code into <code></code> block.




Also See:

  • T : 1.043945