-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaffi.php
executable file
·63 lines (60 loc) · 1.63 KB
/
affi.php
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
<center> <a href="insert.php">ajouter</a> <a href="list.php">lister</a>
</center>
<?php
$user='kagna';
$pass='passer';
// $variable=mysqli_connect('localhost',$user,$pass,'student');
// $sql="select * from etud order by nom";
// $result=mysqli_query($variable,$sql);
// //print_r($result);
// $tab=mysqli_fetch_all($result, MYSQLI_ASSOC);
// echo gettype($result)."<br>";
// echo gettype($tab)."<br>";
// echo gettype($variable)."<br>";
// $_COOKIE["essai"]="diop";
//avec pdo
$variable=new PDO ("mysql:dbname=student;host=localhost",$user,$pass);
$sql="select * from etud ";
$result=$variable->query($sql);
//print_r($result);
$tab=$result->fetchAll($variable::FETCH_ASSOC);//recuperer ts les valeur dans un tableau
//print_r($tab);
//apres on a fais avec foreach
?>
<center>
<table border='1px'>
<tr>
<th>ID</th>
<th>Nom</th>
<th>Prénom</th>
<th>Modifier</th>
<th>Supprimer</th>
</tr>
<?php foreach($tab as $row) {?>
<tr>
<td class="id"><?=$row['id']?></td>
<td class="prenom"><?=$row['nom']?></td>
<td class="nom"><?=$row['prenom']?></td>
<td><a href="update.php?id=<?=$row['id']?>">modifier</a></td>
<td><button class='delete' value="<?=$row['id']?>">supprimer</button></td>
</tr>
<?php } ?>
</table>
</center>
<script>
deletes = document.querySelectorAll('.delete');
deletes.forEach(dele => {
dele.addEventListener('click', () => {
let deles = dele.value;
$.ajax({
type: "POST",
url: "delete.php",
data: { val: deles },
success: function(data) {
location.reload()
}
});
})
})
</script>
<script src="jquery.js"></script>