-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplayers.php
More file actions
52 lines (50 loc) · 1.72 KB
/
players.php
File metadata and controls
52 lines (50 loc) · 1.72 KB
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
<?php
require_once ("connect_db.php");
if(isset($_GET["id"]) && is_numeric($_GET["id"])){
$id = (int) $_GET["id"];
}else{
$id = NULL;
}
?>
<html>
<head>
<title>Players</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<body>
<div class="container">
<h1>Player <?php
$query = $conn->prepare("SELECT name FROM players WHERE id=$id");
$query->execute();
$name = $query->fetch();
echo $name["name"];
?></h1>
<table class="table">
<tr>
<th>#</th>
<th>Name</th>
<th>Class</th>
<th>Team</th>
</tr>
<?php
foreach($conn->query("SELECT * FROM players WHERE id=$id") as $row) {
echo "<tr>";
echo "<td>".$row["id"]."</td>";
echo "<td>".$row["name"]."</td>";
$query = $conn->prepare("SELECT name FROM classes WHERE id=?");
$query->bindParam(1, $row["id_class"], PDO::PARAM_INT);
$query->execute();
$result = $query->fetch();
echo "<td>".$result["name"]."</td>";
$query = $conn->prepare("SELECT name FROM teams WHERE id=?");
$query->bindParam(1, $row["id_team"], PDO::PARAM_INT);
$query->execute();
$result = $query->fetch();
echo "<td>".$result["name"]."</td>";
echo "<tr>";
}
?>
</table>
</div>
</body>
</html>