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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
|
<?php
echo("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n");
/* Variables de connexion : ajustez ces paramètres selon votre propre environnement */
$serveur = "localhost";
$admin = "root";
$mdp = "";
$base = "test";
?>
<html lang="fr">
<head>
<meta content="text/html; charset=windows-1252" http-equiv="content-type">
<link rel="stylesheet" href="style.css">
<title>Ajouter une RNC</title>
</head>
<body style="color:rgb(175,0,124); font-family:arial; background-color : rgb(179,179,179);" >
<?php
$connexion = mysql_pconnect($serveur, $admin, $mdp);
if($connexion != false)
{ $choixbase = mysql_select_db($base, $connexion);
$sql1 = "SELECT num_contrat, nom_client, type_equipement FROM test.commande";
$rech_contrat = mysql_query($sql1);
$num_contrat = array();
$nom_client = array();
$type_equipement = array();
/* On active un compteur pour les contrats */
$nb_contrat = 0;
if($rech_contrat != false)
{ while($ligne = mysql_fetch_assoc($rech_contrat))
{ array_push($num_contrat, $ligne['num_contrat']);
array_push($nom_client, $ligne['nom_client']);
array_push($type_equipement, $ligne['type_equipement']);
/* On incrémente le compteur */
$nb_contrat++;
}
}
?>
<form action="<?php echo($_SERVER['PHP_SELF']); ?>" method="post" id="chgitem">
<!-- IMPUTATION -->
<table name ="Imputation" width = "100%" class= "tabcontrat">
<tbody>
<tr>
<td width = "20%"> <!--label Contrat-->
<label for="contratClient">Contrat :</label>
</td>
<td width = "30%"> <!--input Contrat-->
<select name="contract"; id="contract"; style="width:200px; background-color : rgb(229,229,229);" >
<option value="-1">Numéro de Contrat</option>
<?php
for($i = 0; $i < $nb_contrat; $i++)
{
?>
<option value="<?php echo($num_contrat[$i]); ?>"> <?php echo($num_contrat[$i]); ?> </option>
<?php
}
?>
</select>
</td>
</tr>
<tr>
<td width = "20%"> <!--label Item-->
<label for="item">Item :</label>
</td>
<td width = "30%"> <!--input Item-->
<?php
mysql_free_result($rech_contrat);
/*echo ($_POST['contract']);*/
/* On commence par vérifier si on a envoyé un numéro de contrat et le cas échéant s'il est différent de -1 */
/*if(isset ($_POST['contract']) && ($_POST['contract']) != -1)*/
/*{
echo ($num_contrat[1]);
/* Création de la requête pour avoir les items de ce contrat */
$sql2 = "SELECT num_item, designation_item FROM test.item where contrat=\"" .$_POST['contract']. "\";";
if($connexion != false)
{ $rech_item = mysql_query($sql2, $connexion);
/* Un compteur pour les items */
$nd = 0;
/* On crée deux tableaux pour les numéros et les noms des items */
$num_item = array();
$desig_item = array();
/* On va mettre les numéros et noms des départements dans les deux tableaux */
while($ligne_item = mysql_fetch_assoc($rech_item))
{
array_push($num_item, $ligne_item['num_item']);
array_push($desig_item, $ligne_item['designation_item']);
$nd++;
}
echo ($nd);
/* Maintenant on peut construire la liste déroulante */
?>
<select name="item" id="item" style="width:175px; background-color : rgb(229,229,229);">
<?php
for($d = 0; $d<$nd; $d++)
{
?>
<option value="<?php echo($code_item[$d]); ?>"<?php echo((isset($item_selectionne) && $item_selectionne == $code_item[$d])?" selected=\"selected\"":null); ?>><?php echo($num_item[$d]." - ". $desig_item[$d] .""); ?></option>
<?php
}
?>
</select>
<?php
}
/* Un petit coup de balai */
mysql_free_result($rech_item);
/*}*/
?>
</td>
</tr>
</tbody>
</table><br><br>
</form>
<?php
/* Terminé, on ferme la connexion */
mysql_close($connexion);
}
else
{
?>
<p>Un incident s'est produit lors de la connexion à la base de données, veuillez essayer à nouveau ultérieurement.</p>
<?php
}
?>
</body>
</html> |
Partager