Bonjour à toi ,
Merci pour la réponse, étant débutant, je n'ai pas beaucoup de bagage technique pour faire un code optimal , donc je bricole en quelque sorte .
voici mon code :
<?php
$req = mysql_query('select * from installhlr');
?>
<form action="modifhlr.php" method="POST">
<?php
while($dnn = mysql_fetch_array($req))
{
echo "<tr>";
echo "<td class='left'><input type='hidden' name='id' value=".$dnn['id']."></td>";
echo "<td class='left'><input type='text' name='type' value=".$dnn['type']."></td>";
echo "<td class='left'><input type='text' name='priorite' value=".$dnn['priorite']."></td>";
echo "<td class='left'><input type='text' name='date' value=".$dnn['date']."></td>";
echo "<td class='left'><input type='text' name='tech' value=".$dnn['tech']."></td>";
echo "<td class='left'><input type='text' name='mid' value=".$dnn['mid']."></td>";
echo "<td class='left'><input type='text' name='offre' value=".$dnn['offre']."></td>";
echo "<td class='left'><input type='text' name='loopback' value=".$dnn['loopback']."></td>";
echo "<td class='left'><input type='text' name='ligne' value=".$dnn['ligne']."></td>";
if ($dnn['statut'] == "RFT")
{
echo "<td class='left' style='background-color:green'><input type='text' name='statut' value=".$dnn['statut']."></td>";
}
else if ($dnn['statut'] == "FAILED")
{
echo "<td class='left' style='background-color:red'><input type='text' name='statut' value=".$dnn['statut']."></td>";
}
else if ($dnn['statut'] == "RFNI")
{
echo "<td class='left' style='background-color:orange'><input type='text' name='statut' value=".$dnn['statut']."></td>";
}
else if ($dnn['statut'] == "FAULT")
{
echo "<td class='left' style='background-color:grey'><input type='text' name='statut' value=".$dnn['statut']."></td>";
}
echo "<td class='left'><input type='text' name='cause' value=".$dnn['cause']."></td>";
echo "<td class='left'><input type='text' name='statutoptedis' value=".$dnn['statutoptedis']."></td>";
echo "<td class='left'><textarea name='commentaires'> ".$dnn['commentaires']."</textarea></td>";
echo "<td class='left'><input type='text' name='semaine' value=".$dnn['semaine']."></td>";
echo "<td class='left'><input type='text' name='techmer' value=".$dnn['techmer']."></td>";
echo "<td class='left'><input type='text' name='autonomie' value=".$dnn['autonomie']."></td>";
echo "<td class='left'><textarea name='comautonomie'> ".$dnn['comautonomie']."</textarea></td>";
echo "<td class='left'><input type='text' name='defaillanceintegrateur' value=".$dnn['defaillanceintegrateur']."></td>";
echo "<td class='left'><textarea name='comdefaillanceintegrateur'> ".$dnn['comdefaillanceintegrateur']."</textarea></td>";
echo "<td class='left'><input type='text' name='repriserft' value=".$dnn['repriserft']."></td>";
echo "<td class='left'><textarea name='comrepriserft'> ".$dnn['comrepriserft']."</textarea></td>";
echo "<td> <input type='submit' name='form1' value='envoyer'></td>";
echo "</tr>";
}
?>
ceci est mon affichage, avec des input donc pour pouvoir modifier
<?php
if (isset($_POST["form1"])) {
// On commence par récupérer les champs
if(isset($_POST['type'])) $type=$_POST['type'];
else $type="";
if(isset($_POST['priorite'])) $priorite=$_POST['priorite'];
else $priorite="";
if(isset($_POST['date'])) $date=$_POST['date'];
else $date="";
if(isset($_POST['tech'])) $tech=$_POST['tech'];
else $tech="";
if(isset($_POST['mid'])) $mid=$_POST['mid'];
else $mid="";
if(isset($_POST['offre'])) $offre=$_POST['offre'];
else $offre="";
if(isset($_POST['loopback'])) $loopback=$_POST['loopback'];
else $loopback="";
if(isset($_POST['ligne'])) $ligne=$_POST['ligne'];
else $ligne="";
if(isset($_POST['statut'])) $statut=$_POST['statut'];
else $statut="";
if(isset($_POST['cause'])) $cause=$_POST['cause'];
else $cause="";
if(isset($_POST['statutoptedis'])) $statutoptedis=$_POST['statutoptedis'];
else $statutoptedis="";
if(isset($_POST['commentaires'])) $commentaires=$_POST['commentaires'];
else $commentaires="";
if(isset($_POST['semaine'])) $semaine=$_POST['semaine'];
else $semaine="";
if(isset($_POST['techmer'])) $techmer=$_POST['techmer'];
else $techmer="";
if(isset($_POST['autonomie'])) $autonomie=$_POST['autonomie'];
else $autonomie="";
if(isset($_POST['comautonomie'])) $comautonomie=$_POST['comautonomie'];
else $comautonomie="";
if(isset($_POST['defaillanceintegrateur'])) $defaillanceintegrateur=$_POST['defaillanceintegrateur'];
else $defaillanceintegrateur="";
if(isset($_POST['comdefaillanceintegrateur'])) $comdefaillanceintegrateur=$_POST['comdefaillanceintegrateur'];
else $comdefaillanceintegrateur="";
if(isset($_POST['repriserft'])) $repriserft=$_POST['repriserft'];
else $repriserft="";
if(isset($_POST['comrepriserft'])) $comrepriserft=$_POST['comrepriserft'];
else $comrepriserft="";
$db = mysql_connect('localhost', 'root', '') or die('Erreur de connexion '.mysql_error());
mysql_select_db('optedis',$db) or die('Erreur de selection '.mysql_error());
$sql = "UPDATE installhlr SET type='$type', priorite='$priorite',date='$date', tech='$tech', mid='$mid', offre='$offre', loopback='$loopback', ligne='$ligne', statut='$statut', cause='$cause', statutoptedis='$statutoptedis', commentaires='$commentaires', semaine='$semaine', techmer='$techmer', autonomie='$autonomie', comautonomie='$comautonomie', defaillanceintegrateur='$defaillanceintegrateur', comdefaillanceintegrateur='$comdefaillanceintegrateur', repriserft='$repriserft', comrepriserft='$comrepriserft' WHERE id = ".$_POST['id']."" ;
mysql_query($sql) or die('Erreur SQL !'.$sql.'<br>'.mysql_error());
mysql_close();
header("location: installhlr.php");
}
?>
celui ci est mon code pour le update.
Mon problème est que si j'ai 10 ligne afficher par exemple , je peux modifier la dernière , mais pas les 9 premières .
Merci pour votre aide
