HTML
  Home arrow HTML arrow Page 2 - 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 
Sun Developer Network 
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 - Download and Install


    (Page 2 of 4 )

    Excellent installation instructions are provided by interactivetools at their site so follow them and install htmlArea. However, there is one change you will probably want to make. If you follow the instructions given in the link above, you will need to place any page that uses htmlArea in the “htmlarea” directory. It is much more likely that you will want to access this control from a page in your server’s root directory. To do so, change the line of code that reads, _editor_url = ""; to _editor_url = "htmlarea/"; .

    You can embed an htmlArea control that will work from your root directory using the following code:


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
    <head>
    <title>htmlArea</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="your name" />
    <script language="Javascript1.2"><!-- // load htmlarea
    _editor_url = "htmlarea/"; // URL to htmlarea files
    var win_ie_ver = parseFloat(navigator.appVersion.split("MSIE")[1]);
    if (navigator.userAgent.indexOf('Mac')        >= 0) { win_ie_ver = 0; }
    if (navigator.userAgent.indexOf('Windows CE') >= 0) { win_ie_ver = 0; }
    if (navigator.userAgent.indexOf('Opera')      >= 0) { win_ie_ver = 0; }
    if (win_ie_ver >= 5.5) {
     document.write('<scr' + 'ipt src="' +_editor_url+ 'editor.js"');
     document.write(' language="Javascript1.2"></scr' + 'ipt>');  
    } else { document.write('<scr'+'ipt>function editor_generate() { return false; }</scr'+'ipt>'); }
    // -->
    </script>
    </head>
    <body>
    <script language="JavaScript1.2" defer>
     editor_generate('contents');
    </script>
    <p align="center">
    <textarea name="contents" cols="40" rows="12" readonly>
    </textarea>
    </p>
    </body>
    </html>

    Save this code, upload it to your server’s root directory and try it out. If you’ve done everything correctly you should see an htmlArea in place of the textarea named “contents”. Try out the various features and see what it is capable of.

    Database Table

    Let’s define the database table that will store the contents of an htmlArea. We’ll name the table “items” and give it the following structure:

    Field NameData TypeProperties
    idint(11)PRIMARY KEY
    titlevarchar(35)Not Null
    topicvarchar(35)Not Null
    authorvarchar(15)Not Null
    contentstextNot Null
    whenaddedtimestamp
    reviewedtinyint (4)

    A few more fields than you imagined perhaps, but they all do serve a purpose. The “id” field will be a unique identifier and should probably be “auto_increment” type. “title” and “author” are self explanatory and “contents” will hold what’s typed into the htmlArea. The ‘whenadded’ field is a ‘timestamp’ data type so it will record the date and time that a record is added. Depending upon your needs, the ‘reviewed’ field may or may not be necessary but it will allow you to vet (preview) content before it is posted to your site. For instance, a where clause in your SQL such as, “WHERE reviewed =1”, would keep items not yet reviewed from showing up on your site.

    More HTML Articles
    More By Peter Lavin


     

    HTML ARTICLES

    - Using a 3D HTML Table as a Recordset
    - Building a 3D HTML Table
    - Maximizing and Restoring HTML Images: Layer ...
    - Completing Construction of a Database Form w...
    - Maximizing and Restoring Images in a Tabular...
    - Building the Recordset for an HTML Database ...
    - Laying Out a Database Form with HTML
    - Tabular Database Form Functions with HTML
    - Tabular Database Forms with HTML
    - Using the Find Functions for HTML Database F...
    - Sorting for Database Forms with HTML
    - Edit and Other Database Form Functions with ...
    - More Database Form Functions with HTML
    - Database Form Functions with HTML
    - Using the HTML Table Element as a Recordset






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
    Stay green...Green IT