Whatever message this page gives is out now! Go check it out!
<cfif GetEmployees.RecordCount IS "0"> No records match your search criteria. <BR> <cfelse> |
<html> <head> <title>Retrieving Employee Data Based on Criteria from Form</title> </head> <body> <cfquery name="GetEmployees" datasource="cfdocexamples"> SELECT Departmt.Dept_Name, Employee.FirstName, Employee.LastName, Employee.StartDate, Employee.Salary FROM Departmt, Employee WHERE Departmt.Dept_ID = Employee.Dept_ID <cfif isdefined("Form.Department")> AND Departmt.Dept_Name = <cfqueryparam value="#Form.Department#" CFSQLType="CF_SQL_VARCHAR"> </cfif> <cfif Form.LastName is not ""> AND Employee.LastName = <cfqueryparam value="#Form.LastName#" CFSQLType="CF_SQL_VARCHAR"> </cfif> </cfquery> <cfif GetEmployees.recordcount is "0"> No records match your search criteria. <br> Please go back to the form and try again. <cfelse> <h4>Employee Data Based on Criteria from Form</h4> <table> <tr> <th>First Name</th> <th>Last Name</th> <th>Salary</th> </tr> <cfoutput query="GetEmployees"> <tr> <td>#FirstName#</td> <td>#LastName#</td> <td>#Salary#</td> </tr> </cfoutput> </cfif> </table> </body> </html> |
<html> <head> <title>Your Magic numbers</title> </head> <body> <h1>Your Magic numbers</h1> <P>It will take us a little while to calculate your ten magic numbers. It takes a lot of work to find numbers that truly fit your personality. So relax for a minute or so while we do the hard work for you.</P> <h2>We are sure you will agree it was worth the short wait!</h2> <cfflush> <cfflush interval=10> <!--- Delay Loop to make is seem harder. ---> <cfloop index="randomindex" from="1" to="200000" step="1"> <cfset random=rand()> </cfloop> <!--- Now slowly output 10 random numbers. ---> <cfloop index="Myindex" from="1" to="10" step="1"> <cfloop index="randomindex" from="1" to="100000" step="1"> <cfset random=rand()> </cfloop> <cfoutput> Magic number #Myindex# is: #RandRange( 100000, 999999)#<br><br> </cfoutput> </cfloop> </body> </html> |
| Code | Description | ||
| <h2>We are sure you will agree it was worth the short wait!</h2> <cfflush> | Sends the HTML header and all HTML output to the cfflush tag to the user. This displays the explanatory paragraph and H2 tag contents. | |
| <cfflush interval=10> | Flushes additional data to the user whenever at least 10 bytes are available. | |
| <cfloop index="randomindex" from="1" to="200000" step="1"> <cfset random=Rand()> </cfloop> | Inserts an artificial delay by using the Rand function to calculate many random numbers. | |
| <cfloop index="Myindex" from="1" to="10" step="1"> <cfloop index="randomindex" from="1" to="100000" step="1"> <cfset random=rand()> </cfloop> <cfoutput> Magic number #Myindex# is: #RandRange (100000,999999)#<br><br> </cfoutput> </cfloop> | Generates and displays 10 random numbers. This code uses two loops. The outer loop repeats ten times, once for each number to display. The inner loop uses the Rand function to create another delay by generating more (unused) random numbers. It then calls the RandRange function to generate a six-digit random number for display. |