-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathposts.php
38 lines (31 loc) · 1.16 KB
/
posts.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
<?php
require "database.php";
$stmt = $mysqli->prepare("select username, title, link, id, time from posts");
if (!$stmt) {
printf("Query Prep Failed: %s\n", $mysqli->error);
exit;
}
$stmt->execute();
$stmt->bind_result($username, $title, $link, $id, $time);
?>
<div class="posts">
<?php
while ($stmt->fetch()) {
?>
<div class="post">
<form method="get" action='post.php'>
<button type="submit" class="post__content">
<?php if ($link == "") { ?>
<a class="post__link" href="post.php?id=<?php echo $id; ?>"><?php echo htmlspecialchars($title) ?></a>
<?php } else { ?>
<a class="post__link" href=<?php echo htmlspecialchars($link) ?>><?php echo htmlspecialchars($title) ?> </a>
<?php } ?>
<div class="post__user">posted by <?php echo htmlspecialchars($username) ?> at <?php echo htmlspecialchars($time) ?>
</div>
</button>
<input type='hidden' name='id' value='<?php echo $id; ?>' />
</form>
</div>
<?php
} ?>
</div>