-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathuser.php
More file actions
57 lines (54 loc) · 1.44 KB
/
user.php
File metadata and controls
57 lines (54 loc) · 1.44 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
53
54
55
56
57
<?php
session_start();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<link href="./css/bootstrap.min.css" rel="stylesheet">
<title>Project1</title>
</head>
<body>
<div class="jumbotron" style="margin-bottom: 10px;padding-top: 2px;padding-bottom: 2px;">
<h2 class=page-header style="margin-left: 30px;" ><a href="./">CSCE 608 PROJECT 1 - Music Management Database</a></h2>
</div>
<div class="container">
<h3>User List</h3>
<table class="table">
<thead>
<tr>
<th><a href="?orderBy=id">Id</a></th>
<th><a href="?orderBy=username">Username</a></th>
<th><a href="?orderBy=title">Favorite</a></th>
<th><a href="?orderBy=rate">Rate</a></th>
</tr>
</thead>
<tbody>
<?php
$con = new mysqli("localhost", "root", "rhr5asiq1", "db");
$order = 'id';
$orderBy = array('id', 'username', 'title', 'rate');
if($con->connect_error) {
die("Connection failed: " . $con->connect_error);
}
if(isset($_GET['orderBy']) && in_array($_GET['orderBy'], $orderBy)) {
$order = $_GET['orderBy'];
}
$sql = "SELECT user.id, user.username, music.title, user.rate FROM user INNER JOIN music ON user.favorite=music.id ORDER BY " . $order;
//echo $sql;
$result = $con->query($sql);
while($row = $result->fetch_assoc()) {
echo
"<tr>
<td>" . $row["id"] . "</td>
<td>" . $row["username"] . "</td>
<td>" . $row["title"] . "</td>
<td>" . $row["rate"] . "</td>
</tr>";
}
?>
</tbody>
</table>
</div>
</body>
</html>