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
   |  
<?php
 
include_once('connexion-PDO.php');
$table= "contact";
$sql= 'SELECT DISTINCT nom FROM contact ORDER BY nom ASC';
$sth=$dbh->query($sql);
$row=$sth->fetchAll(PDO::FETCH_COLUMN, 0);
if(isset($_POST['nom']) && trim($_POST['nom'])!=''){
$sql2='DELETE FROM contact WHERE nom= $_POST['nom']';
$gg=$dbh->query($sql2);
echo 'votre contact'.$_POST['nom'].' est bien effacé' ;}
 
if ($dbh) {
$dbh = NULL;}
?>
Lequel de ces contacs voulez-vous supprimer?
<form method="POST" class="search">
		<label for="name">Par nom</label>
		<select name="name" id="name" class="search">
			<option value=""></option>
			<?php
				//cree un item par nom precedemment trouvee dans le fichier XML
				foreach($row as $g){ 
				echo '<option value="', $g, '">', $g, '</option>';}
			?>
		</select>
		<input type="submit" value="OK" />
	</form> | 
Partager