forked from SkyyInfinity/Projet-Vaccination-NFactory
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathread-vaccins.php
64 lines (59 loc) · 2.16 KB
/
read-vaccins.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
64
<?php
session_start();
include('inc/pdo.php');
include('inc/functions.php');
$title = 'Mes vaccins';
// RECUPERE L'ID
if(!empty($_GET['id']) && is_numeric($_GET['id'])) {
$id = $_GET['id'];
$sql = "SELECT * FROM users WHERE id = :id";
$query = $pdo->prepare($sql);
$query->bindValue(':id',$id,PDO::PARAM_INT);
$query->execute();
$user = $query->fetch();
if(empty($user)) {
redirect('404.php');
}
}
// JOINTURE USER/VACCINS
$sql = "SELECT users.id, vaccins.nom, users_vaccins.date_vaccin
FROM users
LEFT JOIN users_vaccins
ON users.id = users_vaccins.id_user
RIGHT JOIN vaccins
ON users_vaccins.id_vaccin = vaccins.id
WHERE users.id = $id";
$query = $pdo->prepare($sql);
$query->execute();
$userVaccins = $query->fetchAll();
include('inc/header.php');
?>
<section class="moncompte-section">
<div class="wrap">
<h2>Mon compte</h2>
<hr>
<div class="moncompte-box">
<nav class="moncompte-nav">
<ul>
<li><a href="mon-compte.php?id=<?php echo $_SESSION['user']['id'] ?>">Mes informations</a></li>
<li><a class="active btn-contrast" href="read-vaccins.php?id=<?php echo $_SESSION['user']['id'] ?>">Mes vaccins</a></li>
<li><a class="danger" href="delete-account.php?id=<?php echo $_SESSION['user']['id'] ?>">Supprimer mon compte</a></li>
</ul>
</nav>
<div class="listing-box">
<div class="add-vaccins">
<p><span>Vaccins ajoutés</span></p>
<a href="add-vaccins.php?id=<?php echo $_SESSION['user']['id'] ?>">Ajouter un vaccin</a>
<a href="admin/admin_relance.php">Relance email</a>
</div>
<?php
for ($i=0; $i<count($userVaccins) ; $i++) {
echo '<p>' . $userVaccins[$i]['nom'] . '</p><span class="date-vaccin">Ajouté le: ' . formatDateWithoutMinute($userVaccins[$i]['date_vaccin']) . '</span>';
};
?>
</div>
</div>
</div>
</section>
<?php
include('inc/footer.php');