Training Center Directory (Behind the Scenes)The Training Center Directory example demonstrates a query and data browsing application used to help people locate training centers which offer courses that meet their needs.
Users enter the first two digits of their zip code and a course (if any) which they are interested in taking. The application returns a list of training centers which match the criteria, and then allows the user to retrieve additional information on selected training centers.
This example demonstrates several important techniques including:
File Name Type Function
MAIN.DBM Template Allows the user to specify
criteria for locating training
centers.
CENTERS.DBM Template Displays the list of centers
matching the criteria specified
in MAIN.HTM.
MOREINFO.DBM Template Displays additional detail
information on centers
selected in CENTERS.DBM.
COURSES.DBM Template Displays the list of courses
offered by a center (called
from MOREINFO.DBM).
<HTML>
<HEAD>
<TITLE>Training Center Directory Example</TITLE>
</HEAD>
<BODY>
<H1>Training Center Directory Example</H1>
<a href="/cfstand/examples/training/details.htm">
<img src="/cfstand/examples/how.gif" border=0 align=middle></a>
<a href="/cfstand/examples/training/details.htm">Behind the Scenes</a>
<HR>
<P>
<H3>Locate WebDeveloper Training Centers</H3>
<P>Certified WebDeveloper Training Centers offer California's
highest-quality education and training for World Wide Web
development. From getting you started surfing the net to
advanced Java programming, we cover all of the bases.
<!-- Query to lookup available courses. The Courses SELECT
box will by dynamically populated with the results
of this query. -->
<DBQUERY NAME="Courses" DATASOURCE="CF Examples"
SQL=" SELECT * FROM Courses ORDER BY Number " >
<FORM ACTION="/~wsapi/cfusion?amp;Template=/cfstand/examples/training/centers.dbm" METHOD=POST>
<PRE>
<INPUT TYPE="submit" value=" Search for Training Centers ">
<B>Region:</B>
Zip Code: <INPUT TYPE="text" Name="Zip" SIZE=10 MAXLENGTH="10"> <I>(Enter first 2 or 3 digits)</I>
(For example data try searching '92', '927', & '94')
<B>Course (Optional):</B>
<SELECT Name="Course">
<OPTION Value="AllCourses" SELECTED>No Specific Course
<DBOUTPUT Query="Courses">
<OPTION Value="#Course_ID#">#Number# - #Description#
</DBOUTPUT>
</SELECT>
</PRE>
</FORM>
<P>
<HR>
[ <a href="/cfstand/examples/examples.htm">Example Applications</a> ]
[ <a href="/cfstand/getstart.htm">Getting Started with Cold Fusion</a> ]
</BODY>
</HTML>
<!-- Search for site matching user criteria. -->
<DBQUERY NAME="Centers" DATASOURCE="CF Examples" MAXROWS=10
SQL=" SELECT DISTINCT Centers.Center_ID, Centers.Name,
Centers.City
FROM Centers, CenterCourses
WHERE CenterCourses.Center_ID = Centers.Center_ID AND
CenterCourses.Course_ID #CourseCriteria# AND
PostalCode Like '%#Zip#%' " >
<HTML>
<HEAD>
<TITLE>Training Center Search Results</TITLE>
</HEAD>
<BODY>
<H2>Training Center Search Results</H2>
<HR>
<DBOUTPUT>
<P>The search located #Centers.RecordCount# training centers
matching your criteria. Select the training centers which
you would like more detailed information on:<P>
</DBOUTPUT>
<FORM ACTION="/~wsapi/cfusion?Template=/cfstand/examples/training/moreinfo.dbm" METHOD=POST>
<!-- Display the list of training centers, embedding a check box in
the first column which will allow the user to select multiple
centers to get more detailed information on. -->
<DBTABLE Query="Centers" COLHEADERS HEADERLINES=2>
<DBCOL WIDTH=1
TEXT="<INPUT Type=checkbox Name=Centers Value=#Center_ID#>">
<DBCOL Header=" <B>Center Name</B>" WIDTH=40 TEXT="#Name#">
<DBCOL Header=" <B>City</B>" WIDTH=25 TEXT="#City#">
</DBTABLE>
<BR>
<INPUT type="hidden" Name="Centers_required"
Value="You must select at least one training center.">
<INPUT type="submit" Value=" Retrieve Detailed Information ">
</FORM>
<HR>
[ <a href="/~wsapi/cfusion?Template=/cfstand/examples/training/main.dbm">Training Center Directory Example</a> ]
[ <a href="/cfstand/examples/examples.htm">Example Applications</a> ]
</BODY>
</HTML>
<!-- Get detailed info on the site -->
<DBQUERY NAME="CenterInfo" DATASOURCE="CF Examples"
SQL=" SELECT * FROM Centers
WHERE Center_ID IN ( #Centers# ) " >
<HTML>
<HEAD>
<TITLE>WebDeveloper Training Center Information</TITLE>
</HEAD>
<BODY>
<H2>WebDeveloper Training Center Information</H2>
<!-- Show the sites information and generate a link to another
template (COURSES.DBM) which will display all courses
offered by the center -->
<DBOUTPUT Query="CenterInfo">
<HR>
<H3>#Name#</H3>
#Address1#<BR>
#City#, #State# #PostalCode#<BR>
Contact: #Contact#<BR>
Phone: #Phone#<P>
[ <a href="/~wsapi/cfusion?Template=/cfstand/examples/training/courses.dbm&Center=#Center_ID#">View Course List</a> ]
<P>
</DBOUTPUT>
<P>
<HR>
[ <a href="/~wsapi/cfusion?Template=/cfstand/examples/training/main.dbm">Training Center Directory Example</a> ]
[ <a href="/cfstand/examples/examples.htm">Example Applications</a> ]
</BODY>
</HTML>
<!-- Determine the name of the training center -->
<DBQUERY NAME="CenterName" DATASOURCE="CF Examples"
SQL=" SELECT Name FROM Centers
WHERE Center_ID = #URL.Center# " >
<!-- Find all of the courses for the training center -->
<DBQUERY NAME="Courses" DATASOURCE="CF Examples"
SQL="SELECT DISTINCT Courses.Number, Courses.Description
FROM CenterCourses, Courses
WHERE Courses.Course_ID = CenterCourses.Course_ID AND
((CenterCourses.Center_ID=#Center#))
ORDER BY Number ">
<HTML>
<HEAD>
<TITLE>Courses Currently Offered</TITLE>
</HEAD>
<BODY>
<H2> Courses Currently Offered</H2>
<HR>
<!-- Display the name as a header -->
<DBOUTPUT QUERY="CenterName">
<H4>Courses Offered by #Name#</H4>
</DBOUTPUT>
<!-- Display the list of courses -->
<DBTABLE QUERY="Courses">
<DBCOL WIDTH=8 TEXT="#Number#">
<DBCOL WIDTH=50 TEXT="#Description#">
</DBTABLE>
<P>
<HR>
[ <a href="/~wsapi/cfusion?amp;Template=/cfstand/examples/training/main.dbm">Training Center Directory Example</a> ]
[ <a href="/cfstand/examples/examples.htm">Example Applications</a> ]
</BODY>
</HTML>