Cold Fusion
Monday, December 6th
Class Notes
Reviewed <cfswitch>:
<CF SWITCH
expression=#deleteaction#>
<CFCASE value="delete">
</CFCASE>
<CFCASE value="add">
</CFCASE>
<CFDEFAULTCASE>
<!--- If none of the above --->
</CFDEFAULTCASE>
</CFSWITCH>
Named several CF tags which do close and those that don't:
DON'T
CLOSE DO CLOSE
Include Loop
Set Query
Locate Transaction
Abort Output
Update If
Else
Param Switch
Case
(Homework: define each
tag listed above in your own words (not the book's) and send to the list.)
Created/modified select pages which sort records in
ascending or descending order by using the following code:
<CFQUERY
datasource="xxxxx"
name="xxxxx">
SELECT
*
FROM
table
<CFIF
isdefined ("sortorder")>
ORDER
BY #sortorder# #SortType#
</cfif>
</CFQUERY>
The page called back to itself using URL parameters to
change the sort order.
<CFOUTPUT>
<A
HREF="mypage.cfm?sortorder=FirstName&SortType=#SortType#">First
Name</A>
</CFOUTPUT>
Notes
- #
variables MUST be enclosed in CFOUTPUT tags to work - for all HTML - even
an <A HREF> tag!
- Multiple
URL parameters are separated by &s.
- No
spaces allowed in URLs!
- To
"remember extra parameters they MUST be passed on the URL line too.
Used <CFPARAM> to avoid undefined variable errors.
<CFPARAM
name="SortOrder" DEFAULT="">
<CFPARAM
name="SortType" DEFAULT="">
Used the SQL ASC and DESC parameters of the ORDER BY clause
for sort type.