Formulaire dans une boucle
Bonjour je souhaite mettre à jour plusieurs enregistrements de ma base mysql à partir de formulaire. Les enregistrements à mettre à jour sont fournis dans *.php??code=x,y,z,...
ce que j'ai fait pour l'instant:
Code:
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
| if (isset ($_GET['code']))
{
$code=$_GET['code'];
mysql_select_db($database,$db);
$query_prod= "select * from catalogue WHERE prod_code IN (".$code.")";
$prod=mysql_query($query_prod,$db) or die(mysql_error($db));
$num_prod=mysql_num_rows($prod);
while ($data = mysql_fetch_array($prod))
{
$supplier=$data['Supplier'];
$prod_code=$data['prod_code'];
$prod_name=$data['prod_name'];
$prod_qte=$data['prod_qte'];
$prod_type=$data['Prod_type'];
$prod_price=$data['prod_price'];
?>
<html>
<head>
<title>Mise à jour du catalogue</title>
<body>
<form action="*.php?code=$code" method="post" name="add" class="Style6">
<p align="center"><strong><span class="Style9">--</span><br>
</strong><em>Mise à jour du catalogue</em></p>
<p align="center"><strong>
</strong></p>
<p align="center"><strong><u>Modification du produit</u></strong></p>
<table width="800px" border="5" align="center" cellpadding="5" cellspacing="0" bgcolor="#eeeeee">
<tr>
<td><span class="Style8">Fournisseur</span></td>
<td colspan="5"><input name="supplier" type="text" id="supplier" style="width:200px" value="<?php echo $supplier;?>">
</td>
</tr>
<tr>
<td><span class="Style8">Code produit</span></td>
<td colspan="5"><input name="codeprod" type="text" id="codeprod" style="width:100px" value="<?php echo $prod_code;?>">
</td>
</tr>
<tr>
<td><span class="Style8">Produit</span></td>
<td colspan="5"> <input name="produit" type="text" id="produit" style="width:325px" value="<?php echo $prod_name;?>"></td>
</tr>
<tr>
<td><span class="Style8">Stock</span></td>
<td colspan="5"> <input name="qte" type="text" id="qte" style="width:20px" value="<?php echo $prod_qte;?>"></td>
</tr>
<tr>
<td><span class="Style8">Type (0= unité / 1= Kg / 2= prix suivant poids )</span></td>
<td colspan="5"> <input name="type" type="text" id="Type" style="width:20px" value="<?php echo $prod_type;?>"></td>
</tr>
<tr>
<td><span class="Style8">Prix(€)</span></td>
<td colspan="5"> <input name="prix" type="text" id="prix" style="width:40px" value="<?php echo $prod_price;?>"></td>
</tr>
<tr>
<td height="50" colspan="6"><div align="center">
<input type="submit" name="modif" value="Modifier ce produit" style="background-color:lightsteelblue;color:black;font-weight:bold ">
</div></td>
</tr>
</table>
</form>
</body>
</html>
<tr>
<?php
}
?> |
Mon problème: comment s'arrêter sur le 1er formulaire (code =x), le renseigner/le compléter, puis cliquer sur "Modifier ce produit" pour faire la mise à jour de la base et ensuite passer à l'affichage du formulaire suivant (code=y) et ainsi de suite?
Pour l'instant ma boucle affiche tous les formulaires sur une même page..et moi, je boucle..
JD
PS: inutile de me dire que les commandes "mysql_" sont périmées, je le sais