Suppression de données d'une base de données
Résolu/Fermé
A voir également:
- Suppression de données d'une base de données
- Effacer les données de navigation - Guide
- Reinstaller windows sans perte de données - Guide
- Célia doit nettoyer le tableau ci-dessous pour l’ajouter à la base de données de son entreprise. les données sont ensuite traitées automatiquement. quelles sont les 4 cellules qui risquent de poser problème ? ✓ - Forum Excel
- Tnt base de données vide - Forum TNT / Satellite / Réception
- Service de diffusion de données - Forum TNT / Satellite / Réception
3 réponses
lili34500
Messages postés
178
Date d'inscription
lundi 11 février 2008
Statut
Membre
Dernière intervention
17 août 2012
16
5 juin 2012 à 08:37
5 juin 2012 à 08:37
voici un code qui marche (tester sur un site en se moment meme)
mysql_connect ('localhost', 'root', '');
mysql_select_db ('ta base');
$sql = 'DELETE from livre_or WHERE id='.$_GET['id'].'';
mysql_query($sql) or die('Erreur SQL !'.$sql.'<br />'.mysql_error());
mysql_close();
mysql_connect ('localhost', 'root', '');
mysql_select_db ('ta base');
$sql = 'DELETE from livre_or WHERE id='.$_GET['id'].'';
mysql_query($sql) or die('Erreur SQL !'.$sql.'<br />'.mysql_error());
mysql_close();
Melooo
Messages postés
1405
Date d'inscription
vendredi 28 novembre 2008
Statut
Membre
Dernière intervention
18 mars 2013
84
5 juin 2012 à 08:46
5 juin 2012 à 08:46
Salut,
Essayes d'afficher ta requête
tu dois bien sur supprimer le header (redirection) pour pouvoir voir le résultat.
Récupères tu bien l'ID ? Si oui, essayes d'éxecuter cette requête dans MySQL
Essayes d'afficher ta requête
$sql=mysql_query("delete from anomalie where code_anomalie='$id'"); echo $sql;
tu dois bien sur supprimer le header (redirection) pour pouvoir voir le résultat.
Récupères tu bien l'ID ? Si oui, essayes d'éxecuter cette requête dans MySQL
merci :) j'ai réglé le problème en utilisant une autre façon d'affichage:
<?php
//connection au serveur:
$cnx = mysql_connect ( "localhost", "root", "" ) ;
//s?lection de la base de donn?es:
$db = mysql_select_db ( "atos" ) ;
//$result=mysql_query ("SELECT * FROM anomalie");
$resultat=mysql_query("select * from anomalie ");
?>
<table width="628" border="1" align="center" cellspacing="0">
<tr bgcolor="#DDDDDD">
<td width="129"><div align="center"><font color="teal"><strong>Code_Anomalie</strong></div></td>
<td width="122"><div align="center"><font color="teal"><strong>Criticité</strong></div></td>
<td width="122"><div align="center"><font color="teal"><strong>Environnement</strong></div></td>
<td width="143"><div align="center"><font color="teal"><strong>ID_Ticket</strong></div></td>
<td width="90"><div align="center"><font color="teal"><strong>Supprimer</strong></div></td>
</tr>
<?php while($row=mysql_fetch_assoc($resultat)) {?>
<tr>
<td><div align="center" class="Style5 Style11"><?php echo $row['code_anomalie'] ;?></div></td>
<td><div align="center" class="Style5 Style11"><?php echo $row['criticité'] ;?></div></td>
<td><div align="center" class="Style5 Style11"><?php echo $row['environnement'] ;?></div></td>
<td><div align="center" class="Style5 Style11"><?php echo $row['ID_ticket'] ;?></div></td>
<td><div align="center" class="Style5 Style11"><a href="supprimer_anomalie.php?id=<?php echo $row['code_anomalie']?>"><a href="supprimer_anomalie.php?id=<?php echo $row['code_anomalie']?>"><img align="middle" src="img/supprimer.png" width="33" height="27" border="0"/></a></div></td>
</tr>
<?php }
mysql_close();
?>
</table>
</body>
</html>
celui ci marche très bien avec le même code de suppression d'avant
<?php
//connection au serveur:
$cnx = mysql_connect ( "localhost", "root", "" ) ;
$db = mysql_select_db ( "atos" ) ;
$id=$_GET['id'];
$sql=mysql_query("delete from anomalie where code_anomalie='$id'");
header("location: afficher_A.php");
?>
<?php
//connection au serveur:
$cnx = mysql_connect ( "localhost", "root", "" ) ;
//s?lection de la base de donn?es:
$db = mysql_select_db ( "atos" ) ;
//$result=mysql_query ("SELECT * FROM anomalie");
$resultat=mysql_query("select * from anomalie ");
?>
<table width="628" border="1" align="center" cellspacing="0">
<tr bgcolor="#DDDDDD">
<td width="129"><div align="center"><font color="teal"><strong>Code_Anomalie</strong></div></td>
<td width="122"><div align="center"><font color="teal"><strong>Criticité</strong></div></td>
<td width="122"><div align="center"><font color="teal"><strong>Environnement</strong></div></td>
<td width="143"><div align="center"><font color="teal"><strong>ID_Ticket</strong></div></td>
<td width="90"><div align="center"><font color="teal"><strong>Supprimer</strong></div></td>
</tr>
<?php while($row=mysql_fetch_assoc($resultat)) {?>
<tr>
<td><div align="center" class="Style5 Style11"><?php echo $row['code_anomalie'] ;?></div></td>
<td><div align="center" class="Style5 Style11"><?php echo $row['criticité'] ;?></div></td>
<td><div align="center" class="Style5 Style11"><?php echo $row['environnement'] ;?></div></td>
<td><div align="center" class="Style5 Style11"><?php echo $row['ID_ticket'] ;?></div></td>
<td><div align="center" class="Style5 Style11"><a href="supprimer_anomalie.php?id=<?php echo $row['code_anomalie']?>"><a href="supprimer_anomalie.php?id=<?php echo $row['code_anomalie']?>"><img align="middle" src="img/supprimer.png" width="33" height="27" border="0"/></a></div></td>
</tr>
<?php }
mysql_close();
?>
</table>
</body>
</html>
celui ci marche très bien avec le même code de suppression d'avant
<?php
//connection au serveur:
$cnx = mysql_connect ( "localhost", "root", "" ) ;
$db = mysql_select_db ( "atos" ) ;
$id=$_GET['id'];
$sql=mysql_query("delete from anomalie where code_anomalie='$id'");
header("location: afficher_A.php");
?>