summaryrefslogtreecommitdiff
path: root/index.php
blob: 08f49283ed1ed77c64aa39eb79dcc7cbb219eafb (plain)
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
<?php
include_once 'header.php';
?>
<section>
	<h2>Welcome to the cflip.net forum!</h2>
	Latest Updates:
	<ul>
		<li>5 latest threads are displayed on the homepage</li>
	</ul>
</section>

	<table>
		<tr>
			<th class="left">Category</th>
			<th class="right">Latest Thread</th>
		</tr>
<?php
	include_once 'includes/db_inc.php';

	$sql = "SELECT cat_id, cat_name, cat_description FROM categories";
	$result = mysqli_query($dbc, $sql);

	if (!$result) {
		die('Failure trying to display categories: ' . mysqli_error($dbc));
	}

	while ($row = mysqli_fetch_assoc($result)) {
		echo '<tr><td class="left">';
		echo '<h4><a href="category.php?id=' . $row['cat_id'] . '">' . $row['cat_name'] . '</a></h4>';
		echo $row['cat_description'];
		echo '</td><td class="right">Example thread<br><small>1 hour ago by <b>example user</b></small></td></tr>';
	}

	mysqli_free_result($result);
?>
	</table>
	<table>
		<tr>
			<th class="left">Latest Threads</th>
			<th class="right">Latest Post</th>
		</tr>
<?php
	include_once 'includes/db_inc.php';

	$sql = "SELECT thread_id, thread_subject, thread_date, user_name FROM threads LEFT JOIN users ON thread_author = user_id ORDER BY thread_id DESC LIMIT 5";
	$result = mysqli_query($dbc, $sql);

	if (!$result) {
		die('Error trying to display threads: ' . mysqli_error($dbc));
	} 

	while ($row = mysqli_fetch_assoc($result)) {
		echo '<tr><td class="left">';
		echo '<h4><a href="thread.php?id=' . $row['thread_id'] . '">' . $row['thread_subject'] . '</a></h4>';
		echo '<small>by <b>' . $row['user_name'] . '</b> on ' . date('M d, Y', strtotime($row['thread_date'])) . '</small></td><td class="right">by <b>cflip</b><br><small>01-22-2021 9:34</small></td></tr>';
	}

	mysqli_free_result($result);
?>
	</table>
<?php
include_once 'footer.php';
?>