Home arrow Site Administration arrow Page 7 - Talk To Me!

Closing The Loop - Administration

You've seen how many Web sites (including this one) allow you topost comments and opinions on the material they publish. If you've everwished you had this capability on your Web site, or are simply curious asto how this is accomplished, read on.

  1. Talk To Me!
  2. The Job
  3. Building The Foundation
  4. Mole In A Hole
  5. Speak Now, Or Forever Hold Your Peace
  6. Of Trees And Branches
  7. Closing The Loop
  8. The Last Word
By: Vikram Vaswani, (c) Melonfire
Rating: starstarstarstarstar / 1
March 12, 2001

print this article


The final piece of the puzzle is the script "details.php", which uses the values passed to it on the URL (article, section and comment identifiers) to query the database and return a single page containing the author's name, the time at which the comment was posted, and the body of the comment. In case the author has included an email address, it is placed within a mailto: hyperlink and printed as well.

<html> <head> <basefont face="Verdana, Arial"> </head> <body> <font face="Verdana, Arial" size="4" color="#66CC00"> Mole In A Hole </font> <p> <font face="Verdana, Arial" size="2" color="Black"> Some things just don't change - at thirty, Adrian Mole is still the whining, unfulfilled loser we first encountered at age 13. He's still writing to the BBC, he's still madly in love with Pandora, now a high-profile politician in Blair's New Britannia, his family is still as dysfunctional as ever. More in our exclusive review of the new Sue Townsend novel. <p> <a href="post.php?section=<? echo $section; ?>&article=<? echo $article; ?>">Comment</a> on this article. <p> <hr> <? include("config.php"); include("common.php"); // connect and get this post $connection = mysql_connect($hostname, $user, $pass) or die ("Unable to connect!"); $query = "SELECT username, email, subject, post, timestamp from $table WHERE id = $id"; $result = mysql_db_query($database, $query, $connection) or die ("Error in query: $query. " . mysql_error()); // display post content list($username, $email, $subject, $post, $timestamp) = mysql_fetch_row($result); // if email address available, place it in a mailto: if ($email) { $email = "<<a href=mailto:" . $email . ">" . $email . "</a>>"; } echo "<font face=verdana size=2 color=black>Posted by <b>$username</b> $email on " . formatDate($timestamp) . "<br>"; echo "<b>Subject</b>: $subject<br>"; echo "<b>Comment:</b> " . nl2br($post) . "</font><p>"; ?> <hr> <a href="post.php?replytopost=<? echo $id; ?>žion=<? echo $section; ?>&article=<? echo $article; ?>">Reply</a> to this post or <a href="list.php?section=<? echo $section; ?>&article=<? echo $article; ?>">read more comments</a> </font> </body> </html>

Here's what it looks like:

Pay special attention to the "reply" link at the bottom of the post - in case a reader wishes to reply to this specific post, the $replytopost variable holds the name of the post that is being replied to. This $replytopost variable is then transferred to "post.php" as an additional parameter and stored in the database, thereby completing the loop required to generate the discussion tree.

The formatDate() function is used to convert the 14-digit mySQL timestamp into something a little more readable.

// format the date correctly function formatDate($val) { // split up the timestamp $year=substr($val,0,4); $month=substr($val,4,2); $day=substr($val,6,2); $hh=substr($val,8,2); $mm=substr($val,10,2); // convert it into a standard timestamp and format it $date = date("d M Y H:i", mktime($hh, $mm, 0, $month, $day, $year)); return $date; }

This article copyright Melonfire 2001. All rights reserved.

>>> More Site Administration Articles          >>> More By Vikram Vaswani, (c) Melonfire

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Coding: Not Just for Developers
- To Support or Not Support IE?
- Administration: Networking OSX and Win 7
- DotNetNuke Gets Social
- Integrating MailChimp with Joomla: Creating ...
- Integrating MailChimp with Joomla: List Mana...
- Integrating MailChimp with Joomla: Building ...
- Integrating MailChimp with Joomla
- More Top WordPress Plugins for Social Media
- Optimizing Security: SSH Public Key Authenti...
- Patches and Rejects in Software Configuratio...
- Configuring a CVS Server
- Managing Code and Teams for Cross-Platform S...
- Software Configuration Management
- Back Up a Joomla Site with Akeeba Backup

Developer Shed Affiliates


Dev Shed Tutorial Topics: