suppression de base de donné
Salut,
J'explique mon problème.
Je suis en train de faire une page web supprimer utilisateur.php " qui me permet de sélectionner tout les champs d'une table "utilisateur" et d'afficher les infos sous forme de tableau puis avec des case a cocher je le droit de supprimer les champs .
Voila le code mais il ne marche pas :(
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
| <?php
//connection au serveur
include('connexion base.php');
if(isset($_POST['supprime'])){
//récupération des checkbox cochées dans un array --------nomme -------> table_array
$table_array=$_POST['table_array'];
$i = 0;
while ( $i < count( $table_array)){
//Mon id de l'enregistrement dans bd se nommé id_user !!!!
$sup= " DELETE nom,prenom,login,password,type_utilisateur FROM utilisateur WHERE id_user= '$table_array[$i]' ";
$test_table = array ($table_array);
print_r($test_table);
exit();
$supp = mysql_query($sup) ;
$i++;
}
}
?>
<script type="text/javascript" src="js/new.js"></script>
<style type="text/css">
<!--
#Layer1 {position:absolute;
left:179px;
top:28px;
width:879px;
height:622px;
z-index:1;
background-image:url(image/gris.jpg);
}
-->
</style>
<div id="Layer1">
<form action="supprimer utilisateur.php" method="post" >
<br />
<h1>supprimer utilisateur: </h1>
<p> </p>
<br />
<center>
<table width="746" align="center">
<tr align="center" bgcolor="#999999">
<td width="20%"><font face="comic sans ms"><b>nom</b></font></td>
<td width="20%"><font face="comic sans ms"><b>prénom</b></font></td>
<td width="35%"><font face="comic sans ms"><b>login</b></font> </td>
<td><font face="comic sans ms"><b>mot de passe</b></font></td>
<td><font face="comic sans ms"><b>type</b></font></td>
<td width="50" bgcolor="#FFB0B0">Delete</td>
</tr>
</table>
<?php
//sélection de la base de données:
include('connexion base.php');
$req= " select nom,prenom,login,password,type_utilisateur from utilisateur";
$rep = mysql_query($req) ;
?>
<?
//affichage
while($row=mysql_fetch_row($rep)){ ?>
$nom=$row[0];
$prenom=$row[1] ;
$login=$row[2];
$password=$row[3];
$type_utilisateur=$row[4];
echo <tr >
<td >:: <? echo $nom ;?></td>
<td>:: <? $prenom; ?></td>
<td><? $login;?> </td>
<td><? $password ;?></td>
<td> <? $type_utilisateur; </td>
echo'<td> <input type='checkbox' name='table_array[$id_user]' value="'.$id_user.'">
</td>
//avec name='table_array[$numero]' value='$numero' -----* > on affiche ainsi mes checkbox :
<input type='checkbox' name='table_array[1]' value='1' />
<tr >
<input type='checkbox' name='table_array[2]' value='2'>
<div align="center">
<input type="submit" name="supprime" value="Supprimer" />
</div>
</center>
</form>
</div> |
Merci de m'aider