Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- mysql_connect ("ephesus.cs.cf.ac.uk", ");
- mysql_select_db
- $sql = "SELECT * FROM php_blog ORDER BY timestamp DESC LIMIT 5";
- $result = mysql_query($sql) or print ("Can't select entries from table php_blog.<br />" . $sql . "<br />" . mysql_error());
- while($row = mysql_fetch_array($result)) {
- $date = date("l F d Y", $row['timestamp']);
- $title = stripslashes($row['title']);
- $entry = stripslashes($row['entry']);
- $password = $row['password'];
- $id = $row['id'];
- if ($password == 1) {
- echo "<p><strong>" . $title . "</strong></p>";
- printf("<p>This is a password protected entry. If you have a password, log in below.</p>");
- printf("<form method=\"post\" action=\"journal.php?id=%s\"><p><strong><label for=\"username\">Username:</label></strong><br /><input type=\"text\" name=\"username\" id=\"username\" /></p><p><strong><label for=\"pass\">Password:</label></strong><br /><input type=\"password\" name=\"pass\" id=\"pass\" /></p><p><input type=\"submit\" name=\"submit\" id=\"submit\" value=\"submit\" /></p></form>",$id);
- print "<hr />";
- }
- else { ?>
- <p><strong><?php echo $title; ?></strong><br /><br />
- <?php echo $entry; ?><br /><br />
- <?php
- $result2 = mysql_query ("SELECT id FROM php_blog_comments WHERE entry='$id'");
- $num_rows = mysql_num_rows($result2);
- if ($num_rows > 0) {
- echo "<a href=\"journal.php?id=" . $id . "\">" . $num_rows . " comments</a>";
- }
- else {
- echo "<a href=\"journal.php?id=" . $id . "\">Leave a comment</a>";
- } ?>
- <hr /></p>
- <?php
- }
- }
- ?>
Add Comment
Please, Sign In to add comment