de liste déroulante affiché valeur tableau?
Posté : 02 mars 2017, 16:03
Bonjour, j'aimerai faire un tableaux a partir d'une liste, par ex : si je choisis toto, je voudrais qu'il sélectionne qui es lié au nom en sachant que les information lié se trouve sur une autre table, es ce que c'est possible et comment dois je mis prendre?
merci
image de ma page
http://www.hostingpics.net/viewer.php?id=518099ex10.png
Merci
merci
Code : Tout sélectionner
<?php
array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'" );
$host = "localhost";
$user = "root";
$pass = "Mm101010";
$dbn = "smartphone";
try{
$bdd = new PDO("mysql:host=".$host.";dbname=".$dbn, $user, $pass, array(
PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8" )
);
$bdd->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$bdd->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
} catch(PDOException $e) {
die('Erreur : ' . $e->getMessage());
}
?>
<!DOCTYPE html>
<html>
<head>
<title></title>
<script>
function selectChoice()
{
var container = $('#Nom_selectionnee');
var selector = $('#choix');
var url = '../php_presque_fini/Tableau_essaie.php';
selector.change(function()
{
var value = $(this).val();
arraySelect = new Array;
$("select option:selected" ).each(function() { arraySelect.push(this.value); });
$.ajax({ url : url, type : 'post', data : {'choix' : arraySelect}, success : function(data){container.html(data);} });
});
}
</script>
</head>
<body>
<div id="content">
<label>Nom :</label>
<select id="selection_Nom" name="choix" onChange="request(this);">
<option value="">-----------</option>
<?php $req = $bdd->query("select * from select_nom_prenom_user group by Nom" );
while($ligne = $req->fetch()) { echo("<option value='choix'>".$ligne['Nom']."</option>" ); } ?>
</select>
<div id="Nom_selectionnee">
<table>
<tr>
<th>Operateur</th>
<th>SIM</th>
<th>PUK</th>
<th>Num ligne</th>
<th>Volume</th>
<th>Statut abo</th>
</tr>
<?php
$choix = ($_POST['choix']);
$selquer = "Select * from select_nom_prenom_user where Nom = '";
$selquer .= $choix;
$selquer .= "' order by Nom asc";
$req = $bdd->query($selquer);
while($ligne = $req->fetch())
{
echo("
<tr>
<td>".$ligne['Operateur']."</td>
<td>".$ligne['Num_SIM']."</td>
<td>".$ligne['PUK']."</td>
<td>".$ligne['Num_ligne']."</td>
<td>".$ligne['Volume']."</td>
<td>".$ligne['Statut_abo']."</td>
</tr>" );
} ?>
</table>
</body>
</html>http://www.hostingpics.net/viewer.php?id=518099ex10.png
Merci