/
frontpage.php
62 lines (52 loc) · 1.51 KB
/
frontpage.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
<!DOCTIYPE html>
<?php
require_once 'lib/common.php';
?>
<html>
<head>
<title>Welcome</title>
<link rel="stylesheet" href="style.css">
<script src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
</head>
<body>
<div id="welcome">
<h5>Welcome <?php echo selectuser($_SESSION['id'])['username']; ?></h5>
<h3>Wanna post something?</h3>
<a href="post.php">
<button name="post">POST</button>
</a><br>
<br>
<form method="post" action="lib/common.php">
<button name="logout">LOGOUT</button>
</form>
</div>
<div id="main">
<?php
echo '<h5>Blogs</h5>';
$db = db();
$stmt = $db->prepare('SELECT * FROM post ORDER BY id DESC');
$result = $stmt->execute();
while ($fetch = $result->fetchArray()) {
echo '<h1>' . selectuser($fetch['user_id'])['username'] . '</h1>';
echo '<a href="postview.php?id=' . $fetch['id'] . '">';
echo '<h3>' . $fetch['tag'] . '</h3>';
echo '<h1>' . $fetch['title'] . '</h1>';
echo '<h4>' . $fetch['created_at'] . '</h4>';
?>
<?php
echo '</a>';
echo '</div>';
}
if ($result->fetchArray() == false) {
echo "<h2>No Entries found :( Be the first one!</h2>";
}
?>
</div>
<script type="text/javascript" src="scripts/jquery.nailthumb.1.1.js"></script>
<script type="text/javascript">
jQuery(document).ready(function () {
jQuery('.nailthumb').nailthumb();
});
</script>
</body>
</html>