I am making the 2 input values to search my database in detail. But in ajax, the script code is good at 1 input value, but poor at 2 input values. So I have show you my codes as like below. First, My html code and script code.
<script>
function showUser1(str)
{
----
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("txtHint10").innerHTML=xmlhttp.responseText;
}
}
var lang20 = document.getElementById('lang20').value;
xmlhttp.open("GET","./database/db1_" +lang20 + ".php?q="+qstr+ "&p="+pstr,true);
xmlhttp.send();
}
</script>
<form>
<select name="lang20" id="lang20" title="choose the language you want">
<option value="co">한국어</option>
<option value="en">English</option>
<option value="af">Afrikaans</option>
</select>
Input: <input name="search" onkeyup="showUser1(this.value)" >
Input: <input name="search" onkeyup="showUser1(this.value)" >
</form>
<div id="txtHint10"><b>Disease information will be listed here.</b></div>
Second, my db1_co.php code is as like below.
<?php
$q = htmlspecialchars($_GET['q']);
$p = htmlspecialchars($_GET['p']);
$con = mysqli_connect('localhost',---);
if (!$con)
{
---
}
mysqli_select_db($con,"ajax_demo");
$sql = "SELECT code_co.code, code_co.disease_co, note.note, inclusion.inclusion,
advertiser.drug, subject.subject, subject.icd_category FROM code_co left join subject
on subject.code=code_co.code left JOIN note ON code_co.code = note.code left JOIN
inclusion ON code_co.code = inclusion.code left JOIN advertiser ON code_co.code =
advertiser.code WHERE code_co.disease_co LIKE '%".$q."%' and code_co.disease_co LIKE
'%".$p."%' OR code_co.code like '%".$q."%' and code_co.code like '%".$p."%'" ;
Above, I guess my script may be wrong. That is, 'php?q="+qstr+ "&p="+pstr,true);' is wrong. Please help me. Give me a piece of advice, please. Thank you for your concern.
qstrandpstrin your js