home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 139 / dpcs0999.iso / Web / CFserver / data1.cab / Examples / employee / Department.cfm < prev    next >
Encoding:
Text File  |  1999-04-12  |  1.9 KB  |  65 lines

  1. <!--- This template displays the employees for any given department and lets
  2.     the user click on an employee to view details. --->
  3.  
  4. <!--- If we weren't given a DepartmentID, this template can't be
  5.     processed; go instead to the employee list --->
  6. <CFIF NOT IsDefined("URL.DepartmentID")>
  7.     <CFLOCATION URL="index.cfm">
  8. </CFIF>
  9.  
  10. <!--- Get department name using department ID (from URL);
  11.     this allows us to display department name in header --->
  12. <CFQUERY NAME="GetDepartmentName" DATASOURCE="CFExamples">
  13. SELECT DepartmentName FROM EmpDepartments
  14. WHERE DepartmentID = #val(URL.DepartmentID)#
  15. </CFQUERY>
  16.  
  17. <!--- Get employees (and their departments); and order by
  18.     department because that's what we're going to group by --->
  19. <CFQUERY DATASOURCE="CFexamples" NAME="GetEmployees">
  20. SELECT * FROM EmpEmployees
  21. WHERE EmpEmployees.DepartmentID = #val(URL.DepartmentID)#
  22. ORDER BY EmpEmployees.DepartmentID, LastName, FirstName
  23. </CFQUERY>
  24.  
  25. <!--- This includes the HTML that goes into the header. --->
  26. <CFINCLUDE TEMPLATE="_header.cfm">
  27.  
  28. <CFOUTPUT QUERY="GetEmployees">
  29.  
  30. <!--- Now we start outputting for every record (i.e. every employee) --->
  31. <TR>
  32.  
  33.        <TD WIDTH=100 ALIGN="RIGHT" VALIGN="TOP" HEIGHT="150"> </TD>
  34.  
  35.     <TD VALIGN="top">
  36.         <FONT FACE="Myriad Web, Verdana, Helvetica" SIZE="+2">
  37.             <!--- Notice we're passing the EmpID in the URL... --->
  38.             <A HREF="Details.cfm?EmpID=#EmpID#">#FirstName# #LastName#</A><BR>
  39.         </FONT>
  40.     
  41.         <FONT FACE="Helvetica">
  42.             <FONT SIZE="-2">#Title#<BR><BR></FONT>
  43.             <FONT SIZE="-1">
  44.                 <CFIF Phone NEQ ""><FONT FACE="WingDings">(</FONT> #Phone#<BR></CFIF>
  45.                 <CFIF Email NEQ ""><FONT FACE="WingDings">*</FONT> <A HREF="mailto:#Email#">#Email#</A><BR></CFIF></P>
  46.             </FONT>
  47.         </FONT>
  48.     </TD>
  49.     
  50.     <TD WIDTH="100" NOWRAP> </TD>
  51.  
  52. </TR>
  53.  
  54. </CFOUTPUT> 
  55.  
  56. <TR>
  57.     <TD HEIGHT="35" COLSPAN="3"> </TD>
  58. </TR>
  59.  
  60. </TABLE>
  61.  
  62. <CFINCLUDE TEMPLATE="_footer.cfm">
  63.  
  64. </BODY>
  65. </HTML>