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
| <?php
include'connect.php';
header('Content-Type: text/html;charset=UTF-8');
if (isset($_POST['valider'])) {
$id=$_POST['id'];
$nom=$_POST['nom'];
$prenom=$_POST['prenom'];
$email=$_POST['email'];
}
/*****************************************************************/
/**** ON INSERT LES INFOS DANS LA TABLE ****/
/***************************************************************/
$req =$pdo->prepare('INSERT INTO doub (id, nom, prenom, email) VALUES (?, ?, ?, ?)');
$req->execute(array($_POST['id'], $_POST['nom'], $_POST['prenom'], $_POST['email']));
/*****************************************************************/
/**** ON SELECTIONNE LES INFOS DANS LA TABLE ****/
/***************************************************************/
$req1=$pdo->prepare("SELECT * from doub as d");
$req1->bindParam(':nom', $nom, PDO::PARAM_STR);
$req1->bindParam(':prenom', $prenom, PDO::PARAM_STR);
$req1->bindParam(':email', $email, PDO::PARAM_STR);
$req1->execute(array($nom,$prenom,$email));
/***************************************************************************/
/****** VALEURS DANS LE TABLEAU ********/
/**************************************************************************/
echo'<table border="1" frame="hsides">
<tr align="center" height="40">
<th><input type=checkbox name=<?php echo $id;?> </th>
<th>Id</th>
<th>Nom</th>
<th>Prénom</th>
<th>Email</th>
</tr>';
$resultats=$pdo->query('SELECT id,nom,prenom,email FROM doub'); // on va chercher tous les membres de la table
foreach ($req1 as $value) {
echo "<tr>";
echo '<td><input type="checkbox" name="supprime[]" value="'.$value['id'] .'"</td>';
echo "<td>".$value['id'].' '."</td>";
echo "<td>".$value['nom'].' '."</td>";
echo "<td>".$value['prenom'].' '."</td>";
echo "<td>".$value['email'].' '."</td>";
echo"</tr>";
}
$resultats->closeCursor(); // on ferme le curseur des résultats
echo "</table>";
echo"<input type=submit value=Supprimer name=suppr>";
if (isset($_POST['suppr'])) {
$pdo->execute('DELETE FROM doub WHERE id='.$_POST['id']);
} |
Partager