Part 1
Part 2
Part 3
Part 4 Feedback Privacy

IDC/HTX - Without help!

If you don't have Access 97, you will have to create your IDC and HTX files by hand. But don't worry, it's not that difficult.

The IDC file is very much like a SQL statement, with a few small differences. You use the IDC file to control the data coming from the database to the web-page, and from the web-page to the database.

The HTX file is a template for how the finished report will look like. It looks very much like a html file, but has a few small extras.

In this tutorial, I'm going to use a simple Contacts database. This has one table called Addresses with the following fields:

FirstName LastName Address City Zip State Phone E-Mail

First, let's create a result page which will list some of the fields for the records returned by the IDC. Using a table for output will, in this case give the desired result. I have numbered the lines for easier reference later.

2. <TBODY>
3. <%begindetail%>
5. <TD><%LastName%></TD>
6. <TD><%FirstName%></TD>
7. <TD><%E-Mail%></TD>
8. </TR>
9. <%enddetail%>

Not included here is all the default HTML which has to go on top and bottom of the HTML file. One you have written the template, save it as filename.htx.

The major differences here between a "normal" table can be seen in lines 3 and 9. These two lines defines the area where the data will be placed. A new table-row will be created for each record returned by the IDC. Also lines 5 through 7 are different. The field names returned by the IDC are all enclosed in percentage characters. These will be replaced by the actual values from the database. The result should look like this:

Hansen Lars
Doe John
Doe Jane

You can easily modify the table to include table-headers etc.

The IDC needed to create this output would look like this:

1. Datasource: Contacts
2. Template: ../template.htx
3. SQLStatement: SELECT DISTINCTROW LastName, FirstName, E-Mail FROM Addresses order by LastName;

Again, I have numbered the lines for easier reference. Line number one refers to the Datasource name (DSN) which where set up earlier using the ODBC setup program. Line number 2 referes to the template file and path you want to use for this IDC. And last, line 3 is the actual SQL Statement. This example will return all records, and sort them by LastName.

You can create this file in a simple text editor. Save it as all.idc in a directory which has the execute attribute set. To view the results page, you will need a hyperlink in another page refering to the IDC. This can be done like this:

<A HREF="cgi_bin/all.idc?">List of all records</A>

If you get an error message when clicking on this hyperlink, it may be that you didn't set the execute attribute for the cgi_bin directory. You don't have to call the directory cgi_bin, you can call it whatever you want, but you must set the execute attribute.

This covers only the basics of getting your database on the internet/intranet. The rest is basically creating the correct SQL statements and HTML code to go with it.

Want more?

© 1999 - 2005 Lars M. Hansen