Faire la mise a jour de ma base de données

Fermé
jogilto Messages postés 7 Date d'inscription samedi 9 décembre 2006 Statut Membre Dernière intervention 8 novembre 2007 - 24 août 2007 à 23:56
 caltoune - 25 août 2007 à 05:04
ici c'est la page modification.php

<?PHP
include("pconnexion.php");
$resultat=mysql_query("select * from etudiant") or die(mysql_error());
if($resultat)
{echo"<center><h1><u>MISE A JOUR DES ETUDIANTS</u></h1></center>";
echo"<table border=2 bgcolor=#BBDDCC width=75%>";
echo"<th>MATRICULE</th>";
echo"<th>NOM</th>";
echo"<th>PRENOM</th>";
echo"<th>AGE</th>";
echo"<th>DATE DE NAISSANCE</th>";
echo"<th>CLASSE</th>";
echo"<th>MODIFICATION</th>";
while($ligne=mysql_fetch_array($resultat))
{ echo"<tr>";
echo"<td>".$ligne['matricule']."</td>";
echo"<td>".$ligne['nom']."</td>";
echo"<td>".$ligne['prenom']."</td>";
echo"<td>".$ligne['age']."</td>";
echo"<td>".$ligne['datenaiss']."</td>";
echo"<td>".$ligne['classe']."</td>";
echo"<td><A HREF=modification1.php?supp=".$ligne['matricule'].">MODIFIER</a></td>";
echo"</tr>";
}
echo"</table>";
}
else
{echo"Echec D'Execution de la Requête.";}
if(isset($_GET['modif']))
{echo"<BR><B><U>OK POUR LA SUPPRESSION</U></B>";
$matri=$_GET['modif'];
$res=mysql_query("update from etudiant where matricule=$matri")or die(mysql_error());
}


?>

ici c'est la page modification1.php
<?PHP
include("pconnexion.php");
$resultat=mysql_query("select * from etudiant") or die(mysql_error());
if($resultat)
{echo"<center><h1><u>MISE A JOUR DES ETUDIANTS</u></h1></center>";
echo"<table border=2 bgcolor=#BOOFF0 width=75%>";
echo"<th>MATRICULE</th>";
echo"<th>NOM</th>";
echo"<th>PRENOM</th>";
echo"<th>AGE</th>";
echo"<th>DATE DE NAISSANCE</th>";
echo"<th>CLASSE</th>";
echo"<th>MODIFICATION</th>";
while($ligne=mysql_fetch_array($resultat))
{ echo"<tr>";
echo"<td>".$ligne['matricule']."</td>";
echo"<td>".$ligne['nom']."</td>";
echo"<td>".$ligne['prenom']."</td>";
echo"<td>".$ligne['age']."</td>";
echo"<td>".$ligne['datenaiss']."</td>";
echo"<td>".$ligne['classe']."</td>";
echo"<td><A HREF=modification2.php?modif=".$ligne['matricule'].">MODIFIER</a></td>";
echo"</tr>";
}
echo"</table>";
}
else
{echo"IMPOSSIBLE D 'AFFICHER.";}

?>

modification2.php

<?PHP
require("pconnexion.php");
$matr=$_GET['modif'];
$res=mysql_query("select*from etudiant where matricule=$matr")or die(mysql_error());
$etudiant=mysql_fetch_array($res);
?>
<form method="post" action="modification3.php">
<input type="hidden" name="matricule" value="<?php echo $etudiant['nom'];?>">
<center><table width="50%" border="2" cellspacing="2" cellpadding="2">
<tr>
<td colspan="2"><div align="center">FORMULAIRE DE MISE A JOUR </div></td>
</tr>
<tr>
<td>NOM</td>
<td><label>
<input name="nom" type="text" value="<?php echo $etudiant['nom'];?>">
</label></td>
</tr>
<tr>
<td>PRENOM</td>
<td><label>
<input name="prenom" type="text" value="<?php echo $etudiant['prenom'];?>">
</label></td>
</tr>
<tr>
<td>AGE</td>
<td><label>
<input name="age" type="text" value="<?php echo $etudiant['age'];?>">
</label></td>
</tr>
<tr>
<td>DATE NAISSANCE</td>
<td><label>
<input name="datenaiss" type="text" value="<?php echo $etudiant['nom'];?>">
</label></td>
</tr>
<tr>
<td>CLASSE</td>
<td><label>
<input name="classe" type="text" value="<?php echo $etudiant['classe'];?>">
</label></td>
</tr>
<tr align="center">
<td colspan="2"><label>

<input type="submit" name="Submit" value="MODIFIER" />

</label></td>

</table>
</form>

modification.3.php

<?php
require("pconnexion.php");
$matricule=$_POST['matricule'];
$nom=$_POST['nom'];
$prenom=$_POST['prenom'];
$age=$_POST['age'];
$datenaiss=$_POST['datenaiss'];
$classe=$_POST['classe'];
$requete="update etudiant set nom='$nom',prenom='$prenom',age='$age',datenaiss='$datenaiss',clase='$classe' where matricule='$matr'";
if($requete)
{echo"la mise à jour de ".$prenom." ".$nom." a été bien efectuée.";
}
else{echo"mise à jour échouée.";
}
?>
bon de la il execute les requetes sans pour autant faire la mise a jour
A voir également:

1 réponse

Bonjour,
le code sql pour ta requete de modification a un probleme.
Le mot clé réservé FROM ne devrait pas en faire partie.

UPDATE UNE_TABLE SET UT_COLONNE = 'valeur' WHERE condition(s)
0