<?php
function Connexion
($Req)
{
$Conn=mysql_connect("loaclhost","root","");
mysql_select_db("gestion");
$result=mysql_query($Req);
return $result ;
}
?>
<html>
<head>
<title>Index </title>
</head>
<body>
<select id="Num">
<?php
$conn=mysql_connect('localhost','root','');
mysql_select_db("testajax");
$resultat=mysql_query("select num from stagiaire ");
while ($line=mysql_fetch_assoc($resultat))
{
echo "<option>".$line['num']."</option>";
}
?>
</select>
<input type="text" id="Nom" />
<input type="text" id="Prenom"/>
<div id="resultat"></div>
<input type="button" value="Charger" onclick="Charger()"/>
<script type="text/javascript">
function Charger()
{
var MyHr= new XMLHttpRequest ;
MyHr.onreadystatechange= function(){
if(MyHr.readyState==4)
{
//alert(1);
response_xml = MyHr.responseXML;
document.getElementById("resultat").innerHTML="Nom :" + response_xml.getElementsByTagName("Nom")[0].textContent ;
document.getElementById("resultat").innerHTML+="<br/>Prenom :" + response_xml.getElementsByTagName("Prenom")[0].textContent ;
}
}
var Num=document.getElementById("Num").value;
MyHr.open("get","Traitement.php?Num="+Num);
MyHr.send(null);
}
</script>
</body>
</html>