Je cherche à mettre à jours une table SQL via un formulaire PHP.
Je connais la commande SQL pour le faire mais je n'arrive pas à mettre en place ce que je veut :
Dans mon tableau il y a des liste déroulantes (1 par ligne) je souhaiterais que la table se mette à jours lorsqu'on change une valeur d'une liste (ou de plusieurs) et qu'on clique sur le bouton enregistrer situé en bas du tableau.
Voici le Code :
Code : Tout sélectionner
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="content-language" content="fr">
<title>Administration</title>
<style type="text/css">
body {
margin: 0;
font-family: Arial;
color: #000000;
font-size: 10pt;
}
a:link {text-decoration: none;}
a:visited {text-decoration: none;}
a:active {text-decoration: none;}
a:hover {text-decoration: none;}
a {color: #333399; font-weight: bold;}
a:hover {color: #FF0000;}
table td {background-color: #CCCCCC; margin: 0; border-width: 0; font-family: Arial; color: #000000; font-size: 10pt;}
.title {background-color: #33CCCC; margin: 0; border-width: 0; font-family: Arial; color: #000000; font-size: 11pt;}
</style>
</head>
<body>
<center><h2>Reste à faire</h2></center>
<?php
include ('include/connexion.php');
$connexion=connexion();
//WHERE etat = 'En cours' OR etat = 'Verification' OR etat = 'Autorisation'
$sql = "SELECT * FROM formulaire ORDER BY `formulaire`.`id` DESC";
$result=mysql_query($sql);
echo "<table border=\"1\" width=\"100%\" align=\"center\">";
echo "<tr>";
echo "<td class=\"title\" align=\"center\"> N° </td>";
echo "<td class=\"title\" align=\"center\"> Identifiant </td>";
echo "<td class=\"title\" align=\"center\"> Nom </td>";
echo "<td class=\"title\" align=\"center\"> Prénom </td>";
echo "<td class=\"title\" align=\"center\"> Service </td>";
echo "<td class=\"title\" align=\"center\"> Téléphone </td>";
echo "<td class=\"title\" align=\"center\"> Nom du site </td>";
echo "<td class=\"title\" align=\"center\"> URL </td>";
echo "<td class=\"title\" align=\"center\"> Catégorie </td>";
echo "<td class=\"title\" align=\"center\"> Motivation de la demande </td>";
echo "<td class=\"title\" align=\"center\"> Date </td>";
echo "<td class=\"title\" align=\"center\"> Etat </td>";
echo "<td class=\"title\" align=\"center\"> Commentaire </td>";
echo "</tr>";
//$tableau = mysql_fetch_array($result);
while ($tableau = mysql_fetch_row($result))
{
$id=$tableau[0];
$identifiant=$tableau[1];
$ndemandeur=$tableau[2];
$prenom=$tableau[3];
$service=$tableau[4];
$telephone=$tableau[5];
$nsi=$tableau[6];
$url=$tableau[7];
$categorie=$tableau[8];
$mdld=$tableau[9];
$date=$tableau[10];
$etat=$tableau[11];
$com=$tableau[12];
?>
<form method="post" action="administration_test.php">
<?php
echo "<tr>";
echo "<td align=\"center\">$id </td>";
echo "<td>$identifiant </td>";
echo "<td>$ndemandeur </td>";
echo "<td>$prenom </td>";
echo "<td>$service </td>";
echo "<td>$telephone </td>";
echo "<td>$nsi </td>";
echo "<td><a href=\"$url\" target=\"_blank\">$url</a> </td>";
echo "<td>$categorie </td>";
echo "<td>$mdld </td>";
echo "<td align=\"center\">$date </td>";
echo "<td align=\"center\"><select size=\"1\" name=\"etat\" value=\"$etat\" tabindex=\"3\">
<option value=\"$etat\">$etat</option>
<option value=\"Verification\">Verification</option>
<option value=\"Autorisation\">Autorisation</option>
<option value=\"Accepter\">Accepter</option>
<option value=\"Refuser\">Refuser</option>
</select></td>";
echo "<td align=\"center\"><textarea rows='5' cols='15' name='comen'>$com</textarea></td>";
echo "</tr>";
$upd = 'UPDATE formulaire SET etat="'.$etat.'" WHERE id="'.$id.'"';
mysql_query($upd);
}
echo "</table>";
echo "<br><center><input type=\"submit\" value=\"Enregistrer\"></center>";
?>
</form>
<br><br>
</body>
</html>
J'ai essayé avec une boucle For et une boucle foreach mais rien à faire je n'y arrive pas
Merci par avance