-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayers.php
67 lines (50 loc) · 1.82 KB
/
players.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
<?php
//Report all PHP errors
error_reporting(E_ALL);
ini_set('display_errors', 'On');
//Connect to database
$mysqli = new mysqli("oniddb.cws.oregonstate.edu","niderk-db","8qV5RXYryvcPMSf8","niderk-db");
/* check connection */
if (mysqli_connect_errno()) {
echo "Connection error " . $mysqli->connect_errno . " " . $mysqli->connect_error;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>CS 275 Project: NHL Database: All Players</title>
<link type="text/css" rel="stylesheet" href="db.css" media="all" />
</head>
<body>
<div id="playersTable" class="statsTable" style="width:50%;">
<h2>All Players:</h2>
<table id="playerTable">
<tr>
<td><strong>Team</strong></td>
<td><strong>Player Name</strong></td>
<td><strong>Jersey #</strong></td>
<td><strong>Position</strong></td>
</tr>
<?php
if(!($stmt = $mysqli->prepare("SELECT TEAMS.teamID, P.playerID, P.firstName, P.lastName, P.jersey, P.position
FROM PLAYERS P
INNER JOIN PLAYERS_TEAMS ON P.playerID = PLAYERS_TEAMS.playerID
INNER JOIN TEAMS ON TEAMS.teamID = PLAYERS_TEAMS.teamID
ORDER BY P.playerID ASC"))){
echo "Prepare failed: " . $stmt->errno . " " . $stmt->error;
}
if(!($stmt->execute())) {
echo "Execute failed ". $stmt->errno . " " . $stmt->error;
}
if(!($stmt->bind_result($teamID, $playerID, $firstName, $lastName, $jersey, $position))){
echo "Bind failed: " . $stmt->errno . " " . $stmt->error;
}
while($stmt->fetch()){
echo '<tr><td>' . $teamID . '</td><td>' . $firstName . ' ' . $lastName . '</td><td>' . $jersey . '</td><td>' . $position . '</td></tr>';
}
?>
</table>
</div> <!-- /playertable -->
</body>
</html>