0

Problem is that i have dynamic changing script for mysql query

<script>
function showUser(str) {
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 (this.readyState == 4 && this.status == 200) {
document.getElementById("txtHint").innerHTML = this.responseText;
}
};

xmlhttp.open("GET","getuser.php?q="+str,true);
xmlhttp.send();
}
}
</script>

I need to get str from this code to php.

from the html point of view i get string from

<select name="users" onchange="showUser(this.value)">

adn in the other file getuser.php I have

$q = $_GET['q'];

$sql="SELECT * FROM articles WHERE type = '".$q."'";

The biggest problem is that i put onchange this parameters so i can get values to my page without refreshing it. But now i cant get value from combobox to php.

How can i do this ???

Thanks in advance

simenesky
  • 3
  • 1

0 Answers0