par
lacfab » 03 févr. 2009, 02:25
Bon voici mon code :
include ("config.php");
switch ($_GET['page']){
default:
echo "<br><br><center>";
// Test si des enregistrements existent sur la palissade sélectionnée.
$affiche = mysql_query("SELECT wt_stockschema_id_palissade FROM WALLTEK_STOCKSCHEMA WHERE wt_stockschema_id_palissade='".$_SESSION['superpal']."'");
$test = mysql_num_rows($affiche);
// Affichage d'une liste d'insert vierge.
if ($test =="0"){
echo "<br><form method='post' name='formulaire' action='BO_palissades_schema.php?page=ajouter'>
<table border='0' class=texte align=center>
<tr>
<td><input type=text size=2 maxlength=1 name='input1'>
<input type=text size=2 maxlength=1 name='input2'>
<input type=text size=2 maxlength=1 name='input3'>
..........
<input type=text size=2 maxlength=1 name='input10'>
</td>
</tr>
</table><br>
<input type='submit' value='Valider ce schéma technique'>
</form>";
}
// Modification des élements.
else{
echo "<br><form method='post' name='formulaire' action='?page=modifier'>";
for($i=1; $i<=$test; $i++){
$input = mysql_fetch_array(mysql_query("SELECT * FROM WALLTEK_STOCKSCHEMA WHERE wt_stockschema_id_palissade='".$_SESSION['superpal']."' AND wt_stockschema_position='".$i."'"));
echo "<input type=text size=2 maxlength=1 name='input".$i."' value='".$input['wt_stockschema_id_module']."'> ";
}
echo "<br><a href='?page=modifier&action=moins' target='b'>-</a> <a href='?page=modifier&action=plus' target='b'>+</a> ";
echo "<br><br>
<input type='submit' value='Valider ce schéma technique'>
</form>";
for($i=1; $i<=$test; $i++){
$img = mysql_fetch_array(mysql_query("SELECT * FROM WALLTEK_STOCKSCHEMA WHERE wt_stockschema_id_palissade='".$_SESSION['superpal']."' AND wt_stockschema_position='".$i."'"));
echo "<img src='graphs/BO_schema_".$img['wt_stockschema_id_module'].".jpg' border=0>";
}
}
break;
case "ajouter":
if ($_POST['input1']!=""){
$req1 = mysql_query("INSERT INTO WALLTEK_STOCKSCHEMA (wt_stockschema_id_palissade, wt_stockschema_id_module, wt_stockschema_position) VALUES('".$_SESSION['superpal']."','".$_POST['input1']."','1')") or die ('ERREUR INSERT 1<br>'. mysql_error());
if ($_POST['input2']!=""){
$req2 = mysql_query("INSERT INTO WALLTEK_STOCKSCHEMA (wt_stockschema_id_palissade, wt_stockschema_id_module, wt_stockschema_position) VALUES('".$_SESSION['superpal']."','".$_POST['input2']."','2')") or die ('ERREUR INSERT 2<br>'. mysql_error());
..........................................
if ($_POST['input10']!=""){
$req10 = mysql_query("INSERT INTO WALLTEK_STOCKSCHEMA (wt_stockschema_id_palissade, wt_stockschema_id_module, wt_stockschema_position) VALUES('".$_SESSION['superpal']."','".$_POST['input10']."','10')") or die ('ERREUR INSERT 10<br>'. mysql_error());
}}}
echo "<meta http-equiv='refresh' content='0; URL=BO_palissades_schema.php'>";
break;
case "modifier":
break;
}
J'ai peut etre pas eu une bonne idée d'imbriquer les if pour ma page d'ajout mais bon y en a que 10 alors ça passera comme ça ;o)
Bon voici mon code :
[php]
include ("config.php");
switch ($_GET['page']){
default:
echo "<br><br><center>";
// Test si des enregistrements existent sur la palissade sélectionnée.
$affiche = mysql_query("SELECT wt_stockschema_id_palissade FROM WALLTEK_STOCKSCHEMA WHERE wt_stockschema_id_palissade='".$_SESSION['superpal']."'");
$test = mysql_num_rows($affiche);
// Affichage d'une liste d'insert vierge.
if ($test =="0"){
echo "<br><form method='post' name='formulaire' action='BO_palissades_schema.php?page=ajouter'>
<table border='0' class=texte align=center>
<tr>
<td><input type=text size=2 maxlength=1 name='input1'>
<input type=text size=2 maxlength=1 name='input2'>
<input type=text size=2 maxlength=1 name='input3'>
..........
<input type=text size=2 maxlength=1 name='input10'>
</td>
</tr>
</table><br>
<input type='submit' value='Valider ce schéma technique'>
</form>";
}
// Modification des élements.
else{
echo "<br><form method='post' name='formulaire' action='?page=modifier'>";
for($i=1; $i<=$test; $i++){
$input = mysql_fetch_array(mysql_query("SELECT * FROM WALLTEK_STOCKSCHEMA WHERE wt_stockschema_id_palissade='".$_SESSION['superpal']."' AND wt_stockschema_position='".$i."'"));
echo "<input type=text size=2 maxlength=1 name='input".$i."' value='".$input['wt_stockschema_id_module']."'> ";
}
echo "<br><a href='?page=modifier&action=moins' target='b'>-</a> <a href='?page=modifier&action=plus' target='b'>+</a> ";
echo "<br><br>
<input type='submit' value='Valider ce schéma technique'>
</form>";
for($i=1; $i<=$test; $i++){
$img = mysql_fetch_array(mysql_query("SELECT * FROM WALLTEK_STOCKSCHEMA WHERE wt_stockschema_id_palissade='".$_SESSION['superpal']."' AND wt_stockschema_position='".$i."'"));
echo "<img src='graphs/BO_schema_".$img['wt_stockschema_id_module'].".jpg' border=0>";
}
}
break;
case "ajouter":
if ($_POST['input1']!=""){
$req1 = mysql_query("INSERT INTO WALLTEK_STOCKSCHEMA (wt_stockschema_id_palissade, wt_stockschema_id_module, wt_stockschema_position) VALUES('".$_SESSION['superpal']."','".$_POST['input1']."','1')") or die ('ERREUR INSERT 1<br>'. mysql_error());
if ($_POST['input2']!=""){
$req2 = mysql_query("INSERT INTO WALLTEK_STOCKSCHEMA (wt_stockschema_id_palissade, wt_stockschema_id_module, wt_stockschema_position) VALUES('".$_SESSION['superpal']."','".$_POST['input2']."','2')") or die ('ERREUR INSERT 2<br>'. mysql_error());
..........................................
if ($_POST['input10']!=""){
$req10 = mysql_query("INSERT INTO WALLTEK_STOCKSCHEMA (wt_stockschema_id_palissade, wt_stockschema_id_module, wt_stockschema_position) VALUES('".$_SESSION['superpal']."','".$_POST['input10']."','10')") or die ('ERREUR INSERT 10<br>'. mysql_error());
}}}
echo "<meta http-equiv='refresh' content='0; URL=BO_palissades_schema.php'>";
break;
case "modifier":
break;
}[/php]
J'ai peut etre pas eu une bonne idée d'imbriquer les if pour ma page d'ajout mais bon y en a que 10 alors ça passera comme ça ;o)