Home arrow HTML arrow Page 4 - Using htmlArea and a Database to Maintain Content on a Website

Using htmlArea and a Database to Maintain Content on a Website

If you wish to develop a website that others can contribute to, one option is to have text files sent as e-mail attachments, convert these to HTML and then upload the file. There is, however, a better way! If the people making submissions to your site are capable of using a word processor then things can be done much more efficiently. This article will show you how to use a free component called htmlArea and a database to handle the addition and display of content on your website. Some knowledge of HTML, databases and server-side scripts is assumed.

Author Info:
By: Peter Lavin
Rating: 5 stars5 stars5 stars5 stars5 stars / 29
May 03, 2004
  1. · Using htmlArea and a Database to Maintain Content on a Website
  2. · Download and Install
  3. · Saving Content
  4. · How to Display the Saved Contents

print this article

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" 
<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">
<!—insert the item here-->
//database information and database functions
include 'connection.php';
include 'dbfunctions.inc';
$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))
if (!($result = @ mysql_query($strsql, $connection))) 
echo "<h3>$row[title]</h3>";
echo "$row[topic]<br />";
echo "$row[contents]";
? >

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.


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.

blog comments powered by Disqus

- Does HTML5 Need a Main Element?
- Revisiting the HTML5 vs. Native Debate
- HTML5: Not for Phone Apps?
- HTML5 or Native?
- Job Hunting? Freelancer.com Lists This Quart...
- HTML5 in the News
- Report: HTML5 Mobile Performance Lags
- The Top HTML5 Audio Players
- Top HTML5 Video Tutorials
- HTML5: Reasons to Learn and Use It
- More of the Top Tutorials for HTML5 Forms
- MobileAppWizard Releases HTML5 App Builder
- HTML5 Boilerplate: Working with jQuery and M...
- HTML5 Boilerplate Introduction
- New API Platform for HTML5

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials