Bonjour a tout le monde
Je fais l'affichage d'une requete dans un tableau
Ce tableau contient "id","titre".
Devant chaque ligne de ce tableau j'ajoute un bouton supprimer.
Dans une autre page, je veux recuperer "id" pour l'utiliser dans une requete pour supprimer cette ligne de ma bdd.
Mon problème se situe au niveau de la recuperation de "id"
voila mon code
affichage :
pour la recuperation de id_produit:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 <?php $host = 'localhost'; // serveur $user = 'root'; // identifiant $mdp = ''; // mot de passe $base = 'ruspina'; // nom de la base // Connexion au serveur mysql_connect($host, $user, $mdp) or die('Impossible de se connecter au serveur '.$host); // Sélection d'une base mysql_select_db($base) or die('Impossible de sélectionner la base '.$base); $result = mysql_query("select * from produit where type=\"film\" ") or die ("Execution impossible de la requete"); $nb1=mysql_num_rows($result); $result1 = mysql_query("select * from film") or die ("Execution impossible de la requete"); $nb2=mysql_num_rows($result1); ?> <table width="169%" border="1"> <tr> <td colspan="14"><div align="center"> <p><img src="image/CATHALOGEFILM.png" width="641" height="139" /></p> </div></td> </tr> <tr> <td width="8%"><span class="Style1">ID_PRODUIT</span></td> <td width="4%"><span class="Style1">TITRE</span></td> <td width="4%"><span class="Style2">ICONE</span></td> <td width="6%"><span class="Style2">POSTURE</span></td> <td width="10%"><span class="Style2"> SYSTEME EXPLOITATION</span> </td> <td width="5%"><span class="Style2">ANNEÉ</span></td> <td width="8%"><span class="Style2">REFERENCE</span></td> <td width="3%"><span class="Style2">PRIX</span></td> <td width="4%"><span class="Style2">POIDS</span></td> <td width="9%"><span class="Style2">REALISATEUR</span></td> <td width="5%"><span class="Style2">ACTEUR</span></td> <td width="6%"><span class="Style2">LANGUE</span></td> <td width="6%"><span class="Style2">ORIGINE</span></td> <td width="12%"><span class="Style2">DUREE</span></td> </tr> <?php if($nb1>0 || $nb2>0) { for($i=0;$i<$nb1;$i++) { $ligne = mysql_fetch_array($result); $ligne2 = mysql_fetch_array($result1); ?> <tr> <td><div align="center"><?php echo $ligne['id_produit']; ?> </div></td> <td><div align="center"><?php echo $ligne['titre']; ?> </div></td> <td><div align="center"> <?php echo $ligne['icone']; ?></div></td> <td><div align="center"><?php echo $ligne['posture']; ?></div></td> <td><div align="center"><?php echo $ligne['systeme_exploitation']; ?> </div></td> <td><div align="center"><?php echo $ligne['annee']; ?> </div></td> <td><div align="center"><?php echo $ligne['reference']; ?> </div></td> <td><div align="center"><?php echo $ligne['prix']; ?> </div></td> <td><div align="center"><?php echo $ligne['poids']; ?> </div></td> <td><div align="center"><?php echo $ligne2['realisateur']; ?> </div></td> <td><div align="center"><?php echo $ligne2['acteur']; ?> </div></td> <td><div align="center"><?php echo $ligne2['langue']; ?> </div></td> <td><div align="center"><?php echo $ligne2['origine']; ?> </div></td> <td><div align="center"><?php echo $ligne2['duree']; ?> </div></td> <td width="10%"><a href="action_supprimer_film.php?pg=<?php echo $ligne[id_produit]; ?>">Supprimer</a></td> <td width="10%"><a href="modifier_film.php?tyty=<?php echo $ligne[id_produit]; ?>">Modifier</a></td> <?php }} ?>
suppresion:
Code : Sélectionner tout - Visualiser dans une fenêtre à part <a href="action_supprimer_film.php?pg=<?php echo $ligne[id_produit]; ?>">Supprimer</a>
je vous remercie
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 <?php if(isset($_GET['pg'])) { $host = 'localhost'; // serveur $user = 'root'; // identifiant $mdp = ''; // mot de passe $base = 'ruspina'; // nom de la base // Connexion au serveur mysql_connect($host, $user, $mdp) or die('Impossible de se connecter au serveur '.$host); // Sélection d'une base mysql_select_db($base) or die('Impossible de sélectionner la base '.$base); $i=$_GET['pg']; $r="delete from produit where id_produit=$i "; $resultat=mysql_query($r); $t="delete from film where id_film=$i "; $resultat=mysql_query($t); } ?>
Partager