Ho trovato ciò che mi servirebbe - ECCO IL LINK -
Solo che non riesco a capire come farlo funzionare su un'unico file.
La prima parte del codice, l'ho copiata così per comè nell'head, il resto l'ho adattato nel body;
il problema che mi esce fuori è: "Notice: Undefined index: q".
Prima parte:
Codice PHP:
<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","index.php?q="+str,true);
xmlhttp.send();
}
</script>
Seconda parte:
Codice PHP:
<select class="shelf_selection" name="users" onchange="showUser(this.value)">
<?php
//ALTRO CODICE
?>
</select>
<?php
$q=$_GET["q"]; //PROBLEMA SEGNALATO "Undefined index: q"
$select2="SELECT libro.titolo FROM libro, sottogenere WHERE (libro.idSottogenere=sottogenere.ID) && (sottogenere.descrizione='$q')";
$result2 = mysql_query($select2);
$riga2 = mysql_fetch_array($result2);
print($riga2['titolo']);
?>