-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex3.php
25 lines (21 loc) · 853 Bytes
/
index3.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
<?php
include 'mysql.php';
echo '<h1>My First Blog</h1>';
echo "<em>Not just another WordPress web log</em><hr/>";
$result = mysqli_query($con,'SELECT * FROM posts ORDER BY date DESC');
if(!mysqli_num_rows($result)) {
echo 'No posts yet.';
} else {
while($row = mysqli_fetch_assoc($result)) {
echo '<h2>'.$row['title'].'</h2>';
$body = substr($row['body'], 0, 300);
echo nl2br($body).'...<br/>';
echo '<a href="post_view.php?id='.$row['id'].'">Read More</a> | ';
echo '<a href="post_view.php?id='.$row['id'].'#comments">'.$row['num_comments'].' comments</a>';
echo '<hr/>';
}
}
echo <<<HTML
<a href="post_add.php">+ New Post</a><br/>
<small>A simple blog based on a <a href="http://programanddesign.com/?p=111" target="_blank">tutorial</a> by <a href="http://programanddesign.com/" target="_blank">Program & Design</a></small>
HTML;