-
Notifications
You must be signed in to change notification settings - Fork 0
/
explore.page.php
51 lines (42 loc) · 1.97 KB
/
explore.page.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
<?php
include 'header.php';
include 'process/dbConn.php'
?>
<html>
<head>
<link href = "styles/post.css" rel='stylesheet' type = "text/css">
</head>
<body>
<ul>
<li></li>
</ul>
<?php
echo "<h1><a href = 'explore.page.php?type=newest'>Newest    </a><a href = 'explore.page.php?type=popular'>Popular    </a><a href = 'explore.page.php?type=trending'>Trending    </a></h1><br><br>";
if (isset($_GET['type'])){
if ($_GET['type'] == 'newest'){
} elseif ($_GET['type'] == 'popular') {
$sql = "SELECT * FROM $tablePosts ORDER BY UpVotes DESC";
$result = $conn->query($sql);
while($row = $result->fetch_assoc()){
$link = "viewpost.page.php?pid=".$row['pid'];
echo "<a href = $link class = 'linkBox'><div class = 'commentBox'><p>Author: $row[Username]</p>
<p>Category: $row[Category]</p>
<p>Date: $row[DatePublished]</p>
<p>$row[Content]</p></div></a><br>";
}
}
} else {
//basically newest
$sql = "SELECT * FROM $tablePosts ORDER BY DatePublished DESC";
$result = $conn->query($sql);
while($row = $result->fetch_assoc()){
$link = "viewpost.page.php?pid=".$row['pid'];
echo "<a href = $link class = 'linkBox'><div class = 'commentBox'><p>Author: $row[Username]</p>
<p>Category: $row[Category]</p>
<p>Date: $row[DatePublished]</p>
<p>$row[Content]</p></div></a><br>";
}
}
?>
</body>
</html>