Bonsoir,
J'ai écris un petit script qui me permet d'afficher les élèves stocker dans une base de données. Mon prob est que l'affichage par classe fonctionne nickel, mais je n'ai pas supprimer un élève.
Or quand je bouge le code d'affichage par classe, le code pour supprimer un élève fonctionne nickel. Je ne comprend vraiment pq ca ne fonctionne pas.
Voici le code source :
<?php require_once('../Connections/ircxl.php'); ?>
<?php
if ((isset($_POST['suppr'])) && ($_POST['suppr'] != "")) {
$id = $_POST['suppr'];
$deleteSQL = sprintf("DELETE FROM eleves WHERE id='$id'");
mysql_select_db($database_ircxl, $ircxl);
$Result1 = mysql_query($deleteSQL, $ircxl) or die(mysql_error());
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Listing élèves</title>
<style type="text/css">
<!--
body,td,th {
font-family: Arial, Helvetica, sans-serif;
color: #FFFFFF;
}
body {
background-color: #006599;
}
a:link {
color: #FFFFFF;
text-decoration: none;
}
a:visited {
color: #FFFFFF;
text-decoration: none;
}
a:hover {
color: #FF0000;
text-decoration: none;
}
a:active {
color: #FF0000;
text-decoration: none;
}
.Style1 {
font-size: x-large;
font-weight: bold;
}
-->
</style></head>
<body>
<table width="745" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="39" colspan="8" bgcolor="#333333"><div align="center"><span class="Style1">Listing élèves </span></div></td>
</tr>
<tr>
<td height="26" colspan="6" bgcolor="#333333"><div align="left">
<form name="classes" method="post" action="">
<label><strong>Afficher :</strong></label><select name="listeclasse" size="1" onChange="this.form.submit();">
<option value="0" >Cliquez ici</option>
<option value="1">1A</option>
<option value="2">2A</option>
<option value="3">3A</option>
<option value="4">3PE</option>
<option value="5">3PG</option>
<option value="6">3QA</option>
</select></form>
</div></td>
<td height="26" bgcolor="#333333"> </td>
<td height="26" bgcolor="#333333"> </td>
</tr>
<tr>
<td width="28" bgcolor="#006599"><strong>id</strong></td>
<td width="106" bgcolor="#006599"><strong>Section</strong></td>
<td width="93" bgcolor="#006599"><strong>Classe</strong></td>
<td width="82" bgcolor="#006599"><strong>Nom</strong></td>
<td width="181" bgcolor="#006599"><strong>Prénom</strong></td>
<td width="63" bgcolor="#006599"><strong>id_clas</strong></td>
<td width="74" bgcolor="#006599"><strong>Modifier</strong></td>
<td width="118" bgcolor="#FF0000"><strong>Supprimer</strong></td>
</tr>
<tr>
<?php
if(isset($_POST['listeclasse']) and is_numeric($_POST['listeclasse']))
{
mysql_select_db($database_ircxl, $ircxl);
$sql1="SELECT eleves.id, eleves.section, eleves.classe, eleves.nom, eleves.prenom, eleves.id_classe, classe.id FROM eleves
inner join classe on classe.id=eleves.id_classe where eleves.id_classe=".$_POST['listeclasse'];
$req=mysql_query($sql1) or die('Erreur SQL! <br>'.$sql1.'<br>'.mysql_error());
while ($row_eleves=mysql_fetch_array($req,MYSQL_ASSOC))
{
?>
<tr>
<td bgcolor="#006599"><?php echo $row_eleves[id]; ?></td>
<td bgcolor="#006599"><?php echo $row_eleves[section]; ?></td>
<td bgcolor="#006599"><?php echo $row_eleves[classe]; ?></td>
<td bgcolor="#006599"><?php echo $row_eleves[nom]; ?></td>
<td bgcolor="#006599"><?php echo $row_eleves[prenom]; ?></td>
<td bgcolor="#006599"><?php echo $row_eleves[id_classe]; ?></td>
<td bgcolor="#006599"><a href="gestioneleves.php">modifier</a></td>
<td bgcolor="#FF0000"><form action="" method="post" name="suppr" id="suppr">
<input name="suppr" type="checkbox" value="<?php echo $row_eleves['id']?>">
<input type="submit" name="Submit" value="supprimer" t>
</form></td>
</tr>
<?php
}
?>
<tr>
<td colspan="8" bgcolor="#333333"><a href="accueiladmin.php">retour</a></td>
</tr>
</table>
<?php
}
mysql_close();
?>
</body>
</html>
Merci d'avance pour à tout ceux qui se pencherons sur mon prob.
++
Stu76 