This repository has been archived by the owner on Mar 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
viewKarateka.php
120 lines (101 loc) · 3.18 KB
/
viewKarateka.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<?php
$title = "Description détaillée d'un karatéka" ;
include 'includes/header.php' ;
if (empty($_POST))
include 'includes/Formulaires/viewKaratekaForm.php';
else{
if (empty($_POST['karateka'])){
echo "karateka non fourni...";
exit();
}
$karateka = $_POST['karateka'];
$vConnect = Connect();
$request = "SELECT * FROM person NATURAL JOIN karateka WHERE id = $karateka;";
if ( !($result = pg_query($vConnect, $request)) ) {
echo pg_last_error() ;
exit();
}
$resultkarateka = pg_fetch_array($result);
if ( !($resultkarateka) ) {
echo pg_last_error() ;
exit();
}
switch ($resultkarateka[belt]){
case white:
$belt = "Blanche"; break;
case yellow:
$belt = "Jaune"; break;
case orange:
$belt = "Orange"; break;
case green:
$belt = "Verte"; break;
case blue:
$belt = "Bleue"; break;
case brown:
$belt = "Marron"; break;
case black:
$belt = "Noire"; break;
default:
echo "couleur ceinture invalide !"; exit();
}
$teacher = $resultkarateka[teacher] ? "Oui" : "Non" ;
?>
<h1>Identité :</h1>
<img src="<?php echo $resultkarateka[urlphoto]; ?>" alt="photo karatéka" height="128" width="128">
<table border=1>
<tr><td>Nom : </td><td><?php echo $resultkarateka[lastname]; ?></td></tr>
<tr><td>Prénom : </td><td><?php echo $resultkarateka[firstname]; ?></td></tr>
<tr><td>Poids : </td><td><?php echo $resultkarateka[weight]; ?></td></tr>
<tr><td>Taille : </td><td><?php echo $resultkarateka[height]; ?></td></tr>
<tr><td>Ceinture : </td><td><?php echo $belt; ?></td></tr>
<?php if ($belt == "Noire"){ ?>
<tr><td>Dans : </td><td><?php echo $resultkarateka[dans]; ?></td></tr>
<?php } ?>
<tr><td>Club : </td><td><?php echo $resultkarateka[clubname]; ?></td></tr>
<tr><td>Professeur :</td><td><?php echo $teacher; ?></td></tr>
</table>
<?php
$request = "SELECT * FROM competition c INNER JOIN participate p ON c.id = p.competition WHERE idk = $karateka;";
if ( !($result = pg_query($vConnect, $request)) ) {
echo pg_last_error() ;
exit();
}
?>
<h1>Compétitions auxquelles <?php echo $resultkarateka[lastname]." ".$resultkarateka[firstname]; ?> a participé :</h1>
<table border=1>
<tr><th>Nom : </th><th>Date : </th><th>Lieu : </th><th>Type : </th><th>Club organisateur : </th></tr>
<?php
$exists = false;
while($resultcompet = pg_fetch_array($result)){
$date = strtotime($resultcompet[date]);
$date = date('d/m/Y', $date);
echo "<tr><td>$resultcompet[name]</td><td>$date</td><td>$resultcompet[place]</td><td>$resultcompet[type]</td><td>$resultcompet[organisator]</td></tr>";
$exists = true;
}
if (!$exists)
echo "<tr><td colspan='5'>Aucune compétition à afficher.</td></tr>";
?>
</table>
<?php
$request = "SELECT kata FROM masteries WHERE karateka = $karateka;";
if ( !($result = pg_query($vConnect, $request)) ) {
echo pg_last_error() ;
exit();
}
?>
<h1>Katas maîtrisés :</h1>
<table border=1>
<tr><th>Nom : </th></tr>
<?php
$exists = false;
while($resultkata = pg_fetch_array($result)){
echo "<tr><td>$resultkata[kata]</td></tr>";
$exists = true;
}
if (!$exists)
echo "<tr><td>Aucun kata maîtrisé.</td></tr>";
?>
</table>
<?php
pg_close($vConnect);
}