C'est plus facile de le faire en Ajax car le PHP ne peut pas traiter le "côté client".
Si tu ne veux pas faire d'Ajax, tu peux "émettreé en PHP tous les tableaux puis les afficher au choix de l'utilisateur. C'est quand même plus compliqué.
Maintenant, l'ajax est devenu assez facile d'utilisation, surtout depuis que des librairies l'ont simplifié. Je pense notamment à Jquery.
Si on reprend ton select appellé "Idselect" (où je ne vois pas de balise fermante d'ailleurs, je l'ai rajouté ...) :
L'HTML :
<TD>
<select name="idselect" id="idselect">
<?php
while ($result = mysql_fetch_array($requete)) {
echo '<option value="'.$result['ID_PRO'].'">'.$result['ID_PRO'].'</option> ' ; //
}
?>
</select>
</TD>
Le javascript :
[javascript]$(document).on({
change : function () {
//on créé un tableau qu'on nomme "resultat" et on lui ajoute les en-têtes
var tab = document.createElement('table');
$(tab).addClass('resultat').append('<tr><th>ID PRO</th><th>Projet Description</th><th>Projet</th>');
//on va rechercher les valeurs sur le serveur
$.ajax ({
url : "serveur.php",
data : {id : $(this).val()},
type : "post",
cache : false,
complete : function (xhr, result) {
if (result != "success") return;
var reponse = xhr.responseText;
var ligne = $(reponse).find('LIGNE');
$(ligne).each(function () {
$(tab).append('<tr><td>'+$(ligne).children('ID_PRO')+'</td><td>'+$(ligne).children('PROJET_DESCRIPTION')+'</td><td>'+$(ligne).children('Projet')+'</td></tr>');
});
$(tab).appendTo('body');
}
});
}
},'#idselect');[/javascript]
Le PHP serveur.php
<?php
//fichier serveur.php
$id = (!empty($_POST["id"]) && is_numeric($_POST["id"])) ? intval($_POST["id"]) : false;
//si id n'est pas un nombre positif => sortie
if (empty($id))
die('L\'id n\'est pas le bon type');
$mysqli = new mysqli("localhost", "user", "password", "database");
if ($mysqli->connect_errno) {
die("Echec lors de la connexion à MySQL : (" . $mysqli->connect_errno . ") " . $mysqli->connect_error);
}
$sql = "SELECT idPro, ProjetDescription, Projet From table where id = ".$id;
$mysqli->real_escape_string($sql); //protection injection Sql
if (!$resultat = $mysqli->query($sql)) {
die ('Erreur dans la requête : (' . $mysqli->errno . ') ' . $mysqli->error);
}
if ($resultat->num_rows == 0) {
die ('Pas de résultats avec l\'id : '.$id);
}
$xmlStr = '<?xml version="1.0" encoding="UTF-8" standalone="no"?><DONNEES>';
while ($s = $resultat->fetch_assoc ()) :
$xmlStr .= '<LIGNE><ID_PRO>'.$s["idPro"].'</ID_PRO><PROJET_DESCRIPTION>'.$s["ProjetDescription"].'</PROJET_DESCRIPTION><PROJET>'.$s["Projet"].'</PROJET></LIGNE>';
endwhile;
$xmlStr = '</DONNEES>';
header ("Content-Type:text/xml");
echo $xmlStr;
?>
C'est plus facile de le faire en Ajax car le PHP ne peut pas traiter le "côté client".
Si tu ne veux pas faire d'Ajax, tu peux "émettreé en PHP tous les tableaux puis les afficher au choix de l'utilisateur. C'est quand même plus compliqué.
Maintenant, l'ajax est devenu assez facile d'utilisation, surtout depuis que des librairies l'ont simplifié. Je pense notamment à Jquery.
Si on reprend ton select appellé "Idselect" (où je ne vois pas de balise fermante d'ailleurs, je l'ai rajouté ...) :
L'HTML :
[html] <TD>
<select name="idselect" id="idselect">
<?php
while ($result = mysql_fetch_array($requete)) {
echo '<option value="'.$result['ID_PRO'].'">'.$result['ID_PRO'].'</option> ' ; //
}
?>
</select>
</TD>[/html]
Le javascript :
[javascript]$(document).on({
change : function () {
//on créé un tableau qu'on nomme "resultat" et on lui ajoute les en-têtes
var tab = document.createElement('table');
$(tab).addClass('resultat').append('<tr><th>ID PRO</th><th>Projet Description</th><th>Projet</th>');
//on va rechercher les valeurs sur le serveur
$.ajax ({
url : "serveur.php",
data : {id : $(this).val()},
type : "post",
cache : false,
complete : function (xhr, result) {
if (result != "success") return;
var reponse = xhr.responseText;
var ligne = $(reponse).find('LIGNE');
$(ligne).each(function () {
$(tab).append('<tr><td>'+$(ligne).children('ID_PRO')+'</td><td>'+$(ligne).children('PROJET_DESCRIPTION')+'</td><td>'+$(ligne).children('Projet')+'</td></tr>');
});
$(tab).appendTo('body');
}
});
}
},'#idselect');[/javascript]
Le PHP serveur.php
[php]<?php
//fichier serveur.php
$id = (!empty($_POST["id"]) && is_numeric($_POST["id"])) ? intval($_POST["id"]) : false;
//si id n'est pas un nombre positif => sortie
if (empty($id))
die('L\'id n\'est pas le bon type');
$mysqli = new mysqli("localhost", "user", "password", "database");
if ($mysqli->connect_errno) {
die("Echec lors de la connexion à MySQL : (" . $mysqli->connect_errno . ") " . $mysqli->connect_error);
}
$sql = "SELECT idPro, ProjetDescription, Projet From table where id = ".$id;
$mysqli->real_escape_string($sql); //protection injection Sql
if (!$resultat = $mysqli->query($sql)) {
die ('Erreur dans la requête : (' . $mysqli->errno . ') ' . $mysqli->error);
}
if ($resultat->num_rows == 0) {
die ('Pas de résultats avec l\'id : '.$id);
}
$xmlStr = '<?xml version="1.0" encoding="UTF-8" standalone="no"?><DONNEES>';
while ($s = $resultat->fetch_assoc ()) :
$xmlStr .= '<LIGNE><ID_PRO>'.$s["idPro"].'</ID_PRO><PROJET_DESCRIPTION>'.$s["ProjetDescription"].'</PROJET_DESCRIPTION><PROJET>'.$s["Projet"].'</PROJET></LIGNE>';
endwhile;
$xmlStr = '</DONNEES>';
header ("Content-Type:text/xml");
echo $xmlStr;
?>[/php]