home *** CD-ROM | disk | FTP | other *** search
/ Australian Personal Computer 1999 April / APC443.iso / features / grpware / coldfus / coldfusi.exe / data1.cab / Documentation / snippets / cfupdate.cfm < prev    next >
Encoding:
Text File  |  1998-10-08  |  2.1 KB  |  63 lines

  1. <!--- This example shows the use of CFUPDATE to change
  2. records in a datasource. --->
  3.  
  4. <!--- if course_ID has been passed to this form, then
  5. perform the update on that record in the datasource --->
  6. <CFIF IsDefined("form.Course_ID")>
  7.   <CFUPDATE DATASOURCE="cfsnippets"
  8.   TABLENAME="Courses" FORMFIELDS="Course_ID,Number,Descript">
  9. </CFIF>
  10.  
  11. <!--- Perform a query to reflect any updated information
  12. if Course_ID is passed through a url, we are selecting a
  13. record to update ... select only that record with the
  14. WHERE clause.
  15.  --->
  16. <CFQUERY NAME="GetCourseInfo" DATASOURCE="cfsnippets">
  17. SELECT     Number, Course_ID, Descript
  18. FROM       Courses
  19. <CFIF IsDefined("url.Course_ID")>
  20. WHERE        Course_ID = #Trim(url.Course_ID)#
  21. </CFIF>
  22. ORDER by Number
  23. </CFQUERY>
  24.  
  25. <HTML>
  26. <HEAD>
  27. <TITLE>CFUPDATE Example</TITLE>
  28. </HEAD>
  29.  
  30. <BODY bgcolor=silver>
  31. <H3>CFUPDATE Example</H3>
  32.  
  33. <!--- If we are updating a record, don't show
  34. the entire list. --->
  35. <CFIF IsDefined("url.Course_ID")>
  36.   <P><H3><a href="cfupdate.cfm">Show Entire List</A></H3>
  37.  
  38.   <FORM METHOD="POST" ACTION="cfupdate.cfm">
  39.   <H3>You can alter the contents of this
  40.   record, and then click "Update" to use
  41.   CFUPDATE and alter the database</H3>
  42.  
  43.   <P>Course Number <INPUT TYPE="Text" NAME="Number" VALUE="<CFOUTPUT>#Trim(GetCourseInfo.Number)#</CFOUTPUT>">
  44.   <P>Course Description<BR>
  45.   <TEXTAREA NAME="Descript" COLS="40" ROWS="5">
  46.   <CFOUTPUT>#Trim(GetCourseInfo.Descript)#</CFOUTPUT>
  47.   </TEXTAREA>
  48.   <BR>
  49.   <INPUT TYPE="Hidden" NAME="Course_ID" VALUE="<CFOUTPUT>#Trim(GetCourseInfo.Course_ID)#</CFOUTPUT>">
  50.   <P><INPUT TYPE="Submit" VALUE="Click to Update">
  51.   </FORM>
  52. <CFELSE>
  53.   <!--- Show the entire record set in CFTABLE form --->
  54.   <CFTABLE QUERY="GetCourseInfo" HTMLTABLE COLHEADERS>
  55.     <CFCOL  TEXT="<a href='cfupdate.cfm?Course_ID=#Trim(Course_ID)#'>Edit Me</a>" WIDTH=10 HEADER="Edit<br>this Entry">
  56.     <CFCOL  TEXT="#Trim(Number)#" WIDTH="4" HEADER="Course Number">
  57.     <CFCOL  TEXT="#Trim(Descript)#" WIDTH=100 HEADER="Course Description">
  58.   </CFTABLE>
  59. </CFIF>
  60.  
  61. </BODY>
  62. </HTML>       
  63.