Administration
  Home arrow Administration arrow Page 7 - Talk To Me!
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ADMINISTRATION

Talk To Me!
By: Vikram Vaswani, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 1
    2001-03-12

    Table of Contents:
  • Talk To Me!
  • The Job
  • Building The Foundation
  • Mole In A Hole
  • Speak Now, Or Forever Hold Your Peace
  • Of Trees And Branches
  • Closing The Loop
  • The Last Word

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
     
    ADVERTISEMENT

    PCmover - $15 Off with Coupon Code CJPH7Q

    Talk To Me! - Closing The Loop
    (Page 7 of 8 )

    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 Administration Articles
    More By Vikram Vaswani, (c) Melonfire


     

       

    ADMINISTRATION ARTICLES

    - Configuring Load-Balanced Clusters
    - Load-Balanced Clusters
    - UNIX Time Format Demystified
    - Making Changes in the CVS
    - Building Your First CVS Repository
    - CVS Quickstart Guide
    - Authorizing Users in Samba
    - Handling User Accounts in Samba
    - Authentication in Samba
    - Accounts, Authentication, and Authorization
    - Advanced Concepts on Dealing with Files and ...
    - Dealing with Files and Filesystems
    - More Hacks for the User Environment in BSD
    - Personalizing the User Environment in BSD
    - Customizing the User Environment in BSD




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway