Con i seguenti due file si realizza uno script AJAX e PHP che interagisce con un database MySQL.

Con una select all'interno di un form, si seleziona un dipendente e contestualmente viene interrogato un database col quale si ottengono informazioni sul dipendente selezionato.

Ho bisogno di modificare lo script inserendo una seconda select nel form in modo da inviare due variabili al secondo file per fare una ricerca più complessa.

potete aiutarmi?


-------- File 1
<script type="text/javascript">
var xmlhttp;

function mostraInfo(str)
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
{
alert ("Browser does not support HTTP Request");
return;
}
var url="mostra_utenti.php";
url=url+"?q="+str;
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function stateChanged()
{
if (xmlhttp.readyState==4)
{
document.getElementById("info").innerHTML=xmlhttp. responseText;
}
}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
{
// code for IE7+, Firefox, Chrome, Opera, Safari
return new XMLHttpRequest();
}
if (window.ActiveXObject)
{
// code for IE6, IE5
return new ActiveXObject("Microsoft.XMLHTTP");
}
return null;
}
</script>

<form>
Seleziona Dipendente:
<select name="users" onChange="mostraInfo(this.value)">
<option selected="selected">seleziona un dipendete...</option>
<option value='1'>Giuseppe Bianco</option>
<option value='3'>Luigi Gallo</option>
<option value='2'>Michele Rossi</option>
<option value='4'>Roberto Viola</option>
</select>
</form>


<div id="info"></div>


-------- File 2
<?php
$q=$_GET["q"];

$con = mysql_connect('xxxx', 'xxxx', 'xxxx');
mysql_select_db("xxxx", $con);

$sql="SELECT * FROM dipendenti WHERE id = '".$q."'";

$result = mysql_query($sql);

echo "<table border='1'>
<tr>
<th>Nome</th>
<th>Cognome</th>
<th>Anni</th>
<th>Lavoro</th>
<th>Stipendio</th>
</tr>";

while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['nome'] . "</td>";
echo "<td>" . $row['cognome'] . "</td>";
echo "<td>" . $row['anni'] . "</td>";
echo "<td>" . $row['lavoro'] . "</td>";
echo "<td>" . $row['stipendio'] . "</td>";
echo "</tr>";
}
echo "</table>";

mysql_close($con);
?>