Created
June 3, 2014 15:14
-
-
Save andrew-dixon/f4a02cd55350e9a79f96 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <cfparam name="URL.searchTerm" default=""> | |
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <title>This is my example..</title> | |
| </head> | |
| <body> | |
| <form action="example.cfm" method="GET"> | |
| <label for="searchTerm">Search: </label> | |
| <input type="text" name="searchTerm" id="searchTerm" value="<cfoutput>#Form.searchTerm#</cfoutput>"/> | |
| <input type="submit"/> | |
| </form> | |
| <cfif URL.searchTerm NEQ ""> | |
| <cfquery name="searchResults"> | |
| SELECT | |
| content.c_id, | |
| content.c_title, | |
| content.c_url | |
| FROM | |
| content | |
| WHERE | |
| c_title LIKE <cfqueryparam cfsqltype="cf_sql_varchar" value="%#URL.searchTerm#%"> | |
| </cfquery> | |
| <cfif searchResults.recordCount GT 0> | |
| <div>#searchResults.recordCount# Results</div> | |
| <div> | |
| <cfloop query="searchResults"> | |
| <div> | |
| <cfoutput><a href="#searchResults.c_url#">#searchResults.c_title#</a></cfoutput> | |
| </div> | |
| </cfloop> | |
| </div> | |
| <cfelse> | |
| <div>No Results</div> | |
| </cfif> | |
| </cfif> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment