J'ai une base de donnée avec 'id' et 'agent' comme champs.
Mon souci est qu'avec mon code ci-dessou:
* Quand on actualise la page, ceci me rajout une entrée dans la base juste un numéro 'id'.
* J'arrive pas a trouver ou est l'erreur dans le code de suprimer.
<html>
<head>
<meta http-equiv="Content-Language" content="fr">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>GESTION DE LA MAIN COURANTE</title>
</head>
<body bgcolor="#E0E0E0"; style="font-family:verdana,Arial,sans-serif; font-size:10pt; overflow:auto; margin:0px; padding:0px;">
<? $URL = $PHP_SELF;
include("connexion.php"); ?>
<? // au réaffichage, on récupère la sélection
if($liste) {
} ?>
<? $table="agent";
$query = "SELECT agent FROM $table ORDER BY `id` DESC ";
$result = mysql_query($query);
?>
<? $table="agent";
$query = "SELECT id FROM $table ORDER BY `id` DESC LIMIT 0, 30 ";
$result2 = mysql_query($query);
?>
<div style="position: fixe; width: 1200px; height: 30px; z-index: 1; left: 10px; top: 15px; background-color:#0000FF; right:20" id="couche1">
<p align="right"><b><font color="#FFFFFF" size="4">GESTION DE LA MAIN COURANTE </font></b></div>
<div style="position: absolute; width: 245px; z-index: 1; left: 0px; top: 30px; id=; height:800px; border-right-style:solid"><p> <?php include("menu.php")?></p></div>
<div style="position: absolute; width: 950px; z-index: 1; left: 249px; top: 30px; background-color:#FFFFFF; height:802px; border-left-style:solid" id="couche3">
<p align="center"><u><i><font color="#008080" size="3"><a name="Haut"></a>Accès Base de donnée</font></i></u></p>
<div align="center">
<hr></div>
<div>
<blockquote>
<p> </p>
</div>
<div>
<hr>
<table border="0" width="100%" cellspacing="3">
<tr>
<td width="383" valign="top">
<p align="center"><i><b><font color="#008080"><a name="BDD_agent"></a>
Vue de la
Base de Donnée agent
</font></b></i>
</p>
<p>
<blockquote>
<p align="center">
<table align="center" border="1" width="81%" cellspacing="0" bgcolor="#CCCCCC" style="border-collapse: collapse">
<tr>
<th width="127"><font size="2">N° d'Id</font></th>
<th width="150"><font size="2">agent</font></th>
</tr>
<?php
include("connexion.php");
$retour = mysql_query('SELECT * FROM agent ORDER BY id DESC');
while ($donnees = mysql_fetch_array($retour))
{
?>
<tr>
<td width="127"> <font size="2"> <?php echo stripslashes($donnees['id']); ?></font></td>
<td width="150"> <font size="2"> <?php echo stripslashes($donnees['agent']); ?></font></td>
</tr>
<?php
}
?>
</table>
</blockquote>
<p> </td>
<td>
<form align="center" method="POST" style="border-width:1px; width: 600; height: 100; background-color:#FFFFFF; text-align:center; " name="Rectification un Agent">
<p align="center" ><b><font color="#008080" size="5">Rectifier un agent</font></b></p>
<blockquote>
<p align="left" ><font color="#008080"><b>Nom de l'agent a changer</b></font><b><font color="#008080"> :
</font></b><select name="champ3">
<? while ($val = mysql_fetch_array($result)) { ?>
<option><? echo $val["agent"]; ?></option>
<? } ?></select> </p>
<p align="left" > <font color="#008080"><b>Nouveau nom de l'agent</b></font><b><font color="#008080">
:</font></b> <input type="text" size="37" name="champ2" > </p>
</blockquote>
<p align="center" >
<input type="submit" value="Modifier" name="B1"> <input type="reset" value="Rétablir" name="B2"></p>
<?php
$champ2=isset($_POST['champ2'])?$_POST['champ2']:"";
$champ3=isset($_POST['champ3'])?$_POST['champ3']:"";
$sql = "SELECT `agent` FROM `agent` WHERE 1";
$modification = mysql_query("UPDATE agent SET agent='$champ2' WHERE agent='$champ3'");
mysql_close();
?>
</form>
<form align="center" method="POST" style="border-width:1px; width: 600; height: 100; background-color:#FFFFFF; text-align:center; " name="Supprimer agent">
<p align="center" ><b><font color="#008080" size="5">Supprimer un agent</font></b></p>
<blockquote>
<p align="left" ><font color="#008080"><b>N° id de l'agent a supprimer: </b></font></b>
<select name="champsup"><? while ($val = mysql_fetch_array($result2)) { ?><option><? echo $val["id"]; ?></option>
<? } ?></select>
</p>
</blockquote>
<p align="center" >
<input type="submit" value="Supprimer" name="B3"> <input type="reset" value="Rétablir" name="B4"></p>
<?php
$champsup=isset($_POST['champsup'])?$_POST['champsup']:"";
$sql = "SELECT `id` FROM `agent` WHERE 1";
$suprimer = mysql_query("DELETE FROM $table WHERE 'agent'.'id'='$champsup'");
mysql_close();
?>
</form>
<form align="center" method="POST" style="border-width:1px; width: 600; height: 100; background-color:#FFFFFF; text-align:center; " name="Nouveau agent">
<p align="center" ><b><font color="#008080" size="5">Nouveau un agent</font></b></p>
<blockquote>
<p align="left" ><font color="#008080"><b>Nom de l'agent a supprimer :</b></font><b><input type="text" name="nouveau_agent" size="20"></font></b></p>
</blockquote>
<p align="center" >
<input type="submit" value="Valider" name="B5">
<input type="reset" value="Rétablir" name="B6"></p>
<?php
include("connexion.php");
mysql_select_db ('agent') ;
$nouveau_agent=isset($_POST['nouveau_agent'])?$_POST['nouveau_agent']:"";
$sql = "SELECT * FROM `agent` WHERE 1";
$nouveau =mysql_query("insert into agent (id,agent) values ('','$nouveau_agent')");
mysql_close();
?>
</form>
</table>
</div>
</body>
</html>
Pouvez vous m'aider ?