Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 78 lines (67 sloc) 2.124 kb
51b11679 »
2010-10-06 Initial commit
1 <?php
2
3 require_once("lib/db.php");
4
5 $post_id = $_GET["id"];
6 $post_result = $db->query("select * from posts where id = '$post_id'");
7 $post = $post_result->fetch_assoc();
8
9 function comments_result($post_id) {
10 global $db;
11
12 return $db->query("select * from comments where post_id = '$post_id'");
13 }
14
15 ?>
f9567435 »
2010-10-07 Put the doctypes after the php always (for
16 <!doctype html>
51b11679 »
2010-10-06 Initial commit
17 <html>
18 <head>
19 <title><?php echo $post["title"] ?> - The Blog</title>
20 </head>
21 <body>
22 <header>
23 <nav>
24 <ul>
25 <li><a href="index.php">Recent Posts</a></li>
26 <li><a href="archive.php">Archive</a></li>
27 </ul>
28 </nav>
29 </header>
30
31 <section id="posts">
32 <article>
33 <header>
34 <h1>
35 <?php echo $post["title"] ?>
36 </h1>
37 </header>
38 <?php echo $post["body_rendered"] ?>
39 <footer>
40 <h1>Comments</h1>
41 <?php
42 $comments_result = comments_result($post["id"]);
43 while ($comment = $comments_result->fetch_assoc()) {
44 ?>
45 <article>
46 <h1><?php echo $comment["name"] ?> said:</h1>
47 <?php echo $comment["body_rendered"] ?>
48 </article>
49 <?php } ?>
50
51 <form action="add_comment.php" method="post">
52 <h1>Add a comment</h1>
53 <input type="hidden" name="comment[post_id]" value="<?php echo $post["id"] ?>">
54 <p>
55 <label for="comment_name">Name:</label>
56 <input type="text" name="comment[name]" id="comment_name">
57 </p>
58 <p>
59 <label for="comment_email">Email:</label>
60 <input type="text" name="comment[email]" id="comment_email">
61 </p>
62 <p>
63 <label for="comment_body">Message:</label>
64 <textarea name="comment[body]" id="comment_body" rows="12" cols="40"></textarea>
65 </p>
66 <p>
67 <button type="submit">Add comment</button>
68 </p>
69 </form>
70
71 </footer>
72 </article>
73 </section>
74
75 </body>
76 </html>
77
Something went wrong with that request. Please try again.