Databases Reference
In-Depth Information
In the preceding listing, there is an additional conditional construct that
looks like
<%if CurrentRecord EQ 0%> any HTML code <%endif%>.
This conditional construct allows for better control over the creation of the
HTML code. In the example, the construct is used to add an AddEntry but-
ton that will activate the add entry screen.
, which
will allow the creation of a completely different HTML code based on the result
set.
Tip: The conditional construct can also contain the element
<%else%>
Warning: The conditional construct will not work if used before the
<%Begin-
Detail%>
.
The CurrentRecord is one of the built-in variables that can be used in the
template. It indicates the current record being processed. If used after, the
construct will hold the last record
number. The record number relates to the sequential number within the re-
sult set.
<%BeginDetail%> <%EndDetail%>
The Add Entry Screen
The Add Entry button will appear on the search results screen only
when there are no records in the result set. Having no records in the result
set will indicate that the entry was not found and therefore may be entered
into the database. The Add Entry button is a submit button within an HTML
form that points to the AddEntry.idc script.
The AddEntry.idc script will fetch the total number of entries in the da-
tabase and invoke the HTML template named AddEntry.htx. Following is
the listing for the AddEntry.idc script:
Datasource:Tel_Directory
Username:
Password:
Template:AddEntry.htx
SQLStatement:
+SELECT count(id) as NumRec from Directory
The AddEntry.htx template is different from the search result template
previously seen. The user only expects one record to be returned to this
screen. That record will contain the total number of records in the data-
base. The rest of the template is an HTML form that will allow the user to
enter the details of the new directory entry and submit them to the data-
base. Exhibit 4 shows the add entry screen.
The following example is the AddEntry.htx HTML listing supporting
Exhibit 4: Add Directory Entry Screen:
Search WWH ::




Custom Search