HTML
  Home arrow HTML arrow Page 4 - Using htmlArea and a Database to Maintain ...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
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? 
HTML

Using htmlArea and a Database to Maintain Content on a Website
By: Peter Lavin
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 20
    2004-05-03

    Table of Contents:
  • Using htmlArea and a Database to Maintain Content on a Website
  • Download and Install
  • Saving Content
  • How to Display the Saved Contents

  • 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


    Using htmlArea and a Database to Maintain Content on a Website - How to Display the Saved Contents


    (Page 4 of 4 )

    The contents will have been saved with the appropriate HTML code and, when retrieved, will need to be integrated into an HTML page. Assuming a hyperlink such as the following:


    <a href="gettext.php?itemnumber=7">About Hermione</a>,

    the contents might be retrieved and displayed using the following “gettext.php” file :



    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
    <head>
    <title>Article</title>
    <meta name="description" content="" />
    <meta name="keywords" content="" />
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    <meta name="author" content="" />
    <link rel="stylesheet" type="text/css" href="style/template.css" title="template" />
    <!--local style elements here-->
    <style type="text/css">
    </style>
    </head>
    <body>
    <!—insert the item here-->
    <?php
    //database information and database functions
    include 'connection.php';
    include 'dbfunctions.inc';
    /**************************************************/
    $itemnumber=@$HTTP_GET_VARS["itemnumber"];
    $strsql = "Select title, description, topic, username, contents, ".
    "Date_Format(whenadded,'%M %e,%Y') AS formatted ".
    "From item WHERE id = $itemnumber";
    $connection = @ mysql_connect($hostname, $username,$password)
    or die("Cannot connect to database");
    if (! mysql_selectdb($databasename, $connection))
     showerror();
    if (!($result = @ mysql_query($strsql, $connection))) 
     showerror();
    $row=mysql_fetch_array($result);
    echo "<h3>$row[title]</h3>";
    echo "$row[topic]<br />";
    echo "$row[contents]";
    ? >
    </body>
    </html>

    You’ll probably want to lay out your page in a more attractive fashion but the above code shows you how any formatting added by the user has been saved to the database and retrieved exactly as the user entered.

    Conclusion

    We have seen how the combination of htmlArea and a database can greatly simplify adding content to a website. This control converts a textarea into a “word processor” giving the user the freedom to format text as (s)he sees fit and it frees the webmaster from having to mark up text. You can cut out the middle man and have content added directly to your site.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

     

    HTML ARTICLES

    - Hello HTML 5, Goodbye Gears
    - Comparing Browser Response to Active Client ...
    - Testing Browser Response to Active Client Pa...
    - Active Client Pages: Completing the Code for...
    - ACP and Browsers: Setting up an Example
    - How Browsers Respond to Active Client Pages
    - Completing a Tree with Active Client Pages
    - HTML Form Verification and ACP
    - Building an ACP Tree
    - Completing an ACP 3D HTML Table Image Gallery
    - Building an ACP 3D HTML Table Image Gallery
    - A Multiple Page Image Gallery with Active Cl...
    - Building an Image Gallery with Active Client...
    - Concluding a Menu for All Browsers
    - A Vertical Menu for All Browsers







    © 2003-2010 by Developer Shed. All rights reserved. DS Cluster 7 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek