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
| <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<link rel="stylesheet" href="Style\styleAjout.css" />
<title>myRPI - Ajout d'une entrée</title>
<script type="text/javascript" src="../javascript/arrayPHP2JS.js" charset="iso_8859-1"></script>
<script type="text/javascript" src="../javascript/changeSousProduit.js" charset="iso_8859-1"></script>
</head>
<header>
<div class="bouton">
<a class="boutonRetour" href="vGestionSousProduit.php">
<h1>Retour</h1>
</a>
</div>
</header>
<body>
<form method="post" action="../controller/cAjoutLiaison.php" id="demoForm" >
<p class="titre">Liaison</p>
<fieldset id="formulaire">
<?php
require_once("../model/connexionBD.php");
$sql = "SELECT idSP as idsp, libelleSP as lsp, Produit.idp as idp, libelleP as lp FROM SousProduit, Produit WHERE SousProduit.idp = Produit.idP ORDER BY Produit.idP;";
$requete = $connexion->prepare($sql);
$requete->execute();
$produit = array();
$id = 0;
$temoin = 0;
foreach($requete->fetchAll() as $p)
{
$pr = $p['idp'];
$sp = $p['idsp'];
if($temoin != $pr)
{
$produit[$pr][0] = $p['lp'];
$produit[$pr][1] = array();
$produit[$pr][2] = array();
$temoin = $pr;
$id = 0;
}
$produit[$pr][1][$id] = $sp;
$produit[$pr][2][$id] = $p['lsp'];
$id++;
}
$chaine = htmlspecialchars(serialize($produit), ENT_QUOTES);
?>
<script type="text/javascript">
/* <![CDATA[ */
<!--
var tableau = new PhpArray2Js('<?php echo $chaine; ?>');
var tab = tableau.retour();
</script>
<legend>Sélectionnez un produit</legend>
<select name="produit" id="produit" onchange="changeSousProduit(tab,this.value);">
<option value="vide">- - - Choisissez un produit - - -</option>
<?php
/* Construction de la première liste : on se sert du tableau PHP */
$nr = count($produit);
foreach($produit as $nbr => $nom)
{
?>
<option value="<?php echo($nr); ?>"><?php echo($nom[0]); ?></option>
<?php
}
?>
</select>
<!-- ICI, le secret : on met un bloc avec un id ou va s'insérer le code de
la seconde liste déroulande -->
<span id="sousProduit">
</span><br />
<label>Categorie :</label>
<select name="idCategorie">
<?php
require_once("../model/connexionBD.php");
$sql = "SELECT libelleC FROM Categorie;";
$requete = $connexion->prepare($sql);
$requete->execute();
foreach($requete->fetchAll() as $p)
{
echo "<option>".$p['libelleC']."</option><br/>";
}
?>
</select>
<label>Contact :</label>
<select name="idContact">
<option></option>
<?php
require_once("../model/connexionBD.php");
$sql = "SELECT nom , prenom FROM Contact;";
$requete = $connexion->prepare($sql);
$requete->execute();
foreach($requete->fetchAll() as $p)
{
echo "<option>".$p['nom']. " " .$p['prenom']. "</option><br/>";
}
?>
</select>
<label>Description :</label>
<input type="text" name="description" size="30" /><br>
</fieldset>
<p id="buttons">
<input type="submit" value="Envoyer" />
<input type="reset" value="Reset" />
</p>
</form>
</body>
</html> |
Partager