Several easy-to-use program HTML extensions provide support for accessing MySQL and mSQL database servers within web pages. In this chapter, we will start with W3-mSQL -- a mSQL-specific tool. We will then show how to take the more database-independent approach with PHP and two minor Perl extensions. The W3-mSQL scripting language, Lite, lets you embed entire programs into an HTML file. A CGI program executes the script and sends the result to the reader as a dynamically created HTML document.
Since W3-mSQL and the other extensions in this chapter use their own scripting languages and hide all evidence of CGI, knowledge of the previous chapters of this section is not necessary for this chapter. However, understanding how CGI works, as well as having some prior programming experience (Lite is similar to both C and Perl), can be useful when reading this chapter.
The World Wide Web's first encounter with what we now call Dynamic HTML was Server Side Includes (SSI). The idea behind SSI is that there are certain common values, such as the current date and time, that would be useful to include in an HTML page but impracticable because they change so often. SSI provided a method by which an HTML page could tell the server to insert a value into the HTML page before sending it to the end user. That way the value would always be current, but the creator of the page would not have to continuously update it. Within an HTML page, a typical SSI directive looks like this:
<!--#echo var="DATE_LOCAL" -->
The problem with SSI is that there is a very limited set of information that the server can easily provide. Once you get past date, time, and the ability to include other files there is not much else available without seriously bloating the web server itself.
It quickly became apparent that if the web server itself did not provide dynamic HTML, it could come from only two other sources. The client -- that is, the web browser -- could interpret the commands or some other program on the server machine could preprocess the commands, outputting plain HTML to the end users.
<SCRIPT> <! onMouseOver("do the jig"); --> </script>
With a server-side interpreter, an HTML document is examined before being sent to the end user. Some program, usually a CGI program, looks for and executes programming code embedded in the HTML. The advantage of this system is that you gain all of the power of a CGI program while hiding much of the complexity.
Consider a marine foundation that has a database containing information about sharks. This database has vital statistics of the various shark species, as well as filenames pointing to images of the creatures. Creating a web interface to this database is an ideal application of server-side interpreted HTML. All of the output pages containing information about a particular shark will be formatted similarly. In the few places where dynamic data from the database is required, commands can be inserted which will be executed before the user sees the page. You can even generate dynamic <IMG> tags that show the desired pictures. Later in the chapter we will look at how to implement this example using a variety of server-side interpreters.
Copyright © 2001 O'Reilly & Associates. All rights reserved.
|This HTML Help has been published using the chm2web software.|