-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresults.php
141 lines (107 loc) · 4.14 KB
/
results.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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?php
session_start();
$activePage = 'results';
if (isset($_SESSION["logged_in"]) && $_SESSION["logged_in"] == true){
//credentials
$host = "303.itpwebdev.com";
$user = "huan981_db_user";
$password = "itp303_test";
$db = "huan981_color_match";
// DB Connection
$mysqli = new mysqli($host, $user, $password, $db);
if ( $mysqli->connect_errno ) {
echo $mysqli->connect_error;
exit();
}
$mysqli->set_charset('utf8');
//get userID corresponding to email
$sql_getID = "SELECT userID from users WHERE email = '" . $_SESSION["email"] . "'";
// echo $sql_getID . "\r\n";
$userID_results = $mysqli->query($sql_getID);
if(!$userID_results) {
echo $mysqli->error;
exit();
}
$userID_array = $userID_results->fetch_assoc();
$userID = $userID_array["userID"];
// echo $userID . "\r\n";
//get all results
$sql_get_results = "SELECT score, date, level FROM results JOIN levels ON results.levelID = levels.levelID WHERE userID = " . $userID . " ORDER BY date DESC;";
$results = $mysqli->query($sql_get_results);
if(!$results) {
echo $mysqli->error;
exit();
}
$mysqli->close();
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Color Matching</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://kit.fontawesome.com/de79172ee1.js" crossorigin="anonymous"></script>
<link rel="stylesheet" type="text/css" href="styles.css">
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@300;400;600&family=Source+Sans+Pro:wght@300;400;600&display=swap" rel="stylesheet">
<style>
body{
background-color: white;
background: none;
}
</style>
</head>
<body>
<?php
include('nav.php');
?>
<div class = "result-header">
<h3 class = "content-title"><?php echo $_SESSION["name"];?>'s Scores</h3>
<!-- sorting dropdown -->
<div class="dropdown">
<button class="btn btn-sm dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Sort By
</button>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item custom-dd" href="#" id="high">High Score</a>
<a class="dropdown-item custom-dd" id = "recent" href="#">Most Recent</a>
<a class="dropdown-item custom-dd" id = "level" href="#">Level</a>
</div>
</div>
</div>
<!-- </div> -->
<div class = "result-gallery">
<?php if ($results->num_rows == 0) : ?>
<div><p>No results yet! Play now!</p></div>
<?php else: ?>
<?php while($row = $results->fetch_assoc()) : ?>
<div class="gallery">
<div class="flip-card-inner">
<div class="flip-card-front <?php echo$row['level']?>">
<h3 class = "score"><?php echo $row['score']; ?></h3>
<h6 class = "level"><?php echo$row['level']?> </h6>
<p class = "date"><?php echo substr($row['date'], 6, 10); ?></p>
</div>
<div class="flip-card-back">
<div class ="back-inner">
<a href="#" class = "delete-link"><i class="far fa-trash-alt fa-2x"></i></a>
<p class = "hidden"><?php echo $row['date']; ?></p>
</div>
</div>
</div>
</div>
<?php endwhile; ?>
<?php endif;?>
</div>
<div class = "footer">
</div>
</body>
<script src="http://code.jquery.com/jquery-3.4.1.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
<script src="https://apis.google.com/js/api:client.js"></script>
<script src="google_login.js"></script>
<script> startApp(); </script>
<script src= "results.js"></script>
</html>