1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
<!-- TEST DU SCRIPT-->
<form method="post">
<select name="tb1" id="tb1"
size=10
onchange='appel();'>
<?php
//==========================================
//== on affiche dans un select la TABLE 1 ==
//==========================================
$res=mysql_query("SELECT NumClient FROM client");
$max=@mysql_num_rows($res);
for ($nb=0;$nb<$max;$nb++)
{ $i=mysql_result($res,$nb,"NumClient");
if ( isset($_POST["tb1"]) && $_POST["tb1"]==$i )
$s=' selected';
else $s='';
echo '<option'.$s.' value="'.$i.'">'.$i.'</option>';
}
?>
</select>
<?php
if (isset($_POST["tb1"]))
{ //==========================================
//== on affiche dans un select la TABLE 2 ==
//==========================================
?>
<select name="tb2" id="tb2"
size=3>
<?php
$rch="WHERE NumClient='".$_POST["tb1"]."'";
$res2=mysql_query("SELECT NumContrat FROM contrat".$rch,$bdd_db);
echo $rch;
echo $res2;
$max=@mysql_num_rows($res2);
for ($nb=0;$nb<$max;$nb++)
{ $i=mysql_result($res2,$nb,"NumContrat");
echo '<option value="'.$i.'">'.$i.'</option>';
}
?>
</select>
<?php
}
?>
<input type="submit" />
</form> |
Partager