Content area
Full text
Preprocessing HTML
E commerce is more than about offering pretty web pages-it's mostly about using and interacting with databases. A classic example of a database used on a web site is, of course, the online product catalog, where product descriptions, prices, and availability are retrieved from a database and offered to customers. If and when a customer completes a purchase, the credit-card number, name, address, and shopping list are recorded. If all goes well, purchased items appear on the customer's doorstep within a few days.
In one recent e-commerce project, I worked with a company wanting to build its own online pharmacy. The client wanted to sell over-the-counter products as well as prescription medicines. Clearly, the application demanded a database. Consequently, I chose Microsoft Access for the database mainly because it is fast, allowing almost instantaneous lookups from a line of more than 18,000 products. To integrate the database with the web site, I then examined three alternatives. In this article, I'll share with you the decisions made, along with the custom system I eventually implemented.
Typical Approaches
Initially, the alternatives I considered included Allaire's Cold Fusion, Microsoft's Internet Database Connector (IDC), and Microsoft's Active Server Pages (ASP).
Cold Fusion (http://www.coldfusion .com/) is a server that processes extensions to HTML. When a web server encounters a request for a particular file type, the web server first passes the file to the Cold Fusion server to preprocess the extended HTML. These extensions consist of extra tags that act as an embedded language. The technique is akin to embedding SQL inside a C program. A preprocessor translates the embedded SQL into C before sending it to the compiler. Cold Fusion scans for code written in the embedded language CFML (short for "Cold Fusion Markup Language"), executes that code, and returns only HTM to the client. The language is fairly complex, letting you query databases and return the result as HTML to the client's browser. Because the language is complex, you can use it for many things using CFML. Example 1 shows how you can generally query a database using CFML.
You embed the SQL between the <CFQUERY> and </CFQUERY> tags. Catalog is the name of a CFML variable that will hold the results of the...





