Three properties are generated for each CFX_SEARCH query that provide information about a particular query:
- RecordCount - The total number of records returned by the query
- CurrentRow - The current row of the query being processed by CFOUTPUT
- RecordsSearched - The total number of records in the index that were searched. If no records were returned, this property returns a null or empty value.
You can use the three available CFX_SEARCH properties in much the same way you use other Cold Fusion system variables. For example, you can easily determine how many records were returned in a search with the following code:
<CFOUTPUT> <P>Your search returned #queryname.RecordCount# records.</P> </CFOUTPUT>
This code presents a message to the user if no records were returned:
<CFIF #cfuser.RecordCount# LTE 0> <CFOUTPUT> <P>Sorry no instances of "#Form.searchquery#" found.</P> </CFOUTPUT> <CFELSEIF #cfuser.RecordCount# GT 0> <CFOUTPUT QUERY="cfuser"> <A HREF="#cfuser.url#">#cfuser.Title#</A><BR> </CFOUTPUT> </CFIF>