Last active
December 28, 2016 13:43
-
-
Save rodionbykov/7da2eec2cdad1be7d6e1f7bade7562d2 to your computer and use it in GitHub Desktop.
cf-101-cfquery-cfoutput-filter
This file contains 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
<html> | |
<body> | |
<form> | |
<select name="userfirstname"> | |
<option value="Anakin">Anakin</option> | |
<option value="Han">Han</option> | |
<option value="">ALL</option> | |
</select> | |
<input type="submit" /> | |
</form> | |
<cfparam name="URL.userfirstname" default="" /> | |
<cfquery datasource="test" name="userlist"> | |
SELECT id, firstname, lastname FROM users | |
<cfif Len(URL.userfirstname) GT 0> | |
WHERE firstname = <cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#URL.userfirstname#" /> | |
</cfif> | |
</cfquery> | |
<table border="1" > | |
<cfoutput query="userlist"> | |
<tr> | |
<td>#id#</td> | |
<td>#firstname# #lastname#</td> | |
</tr> | |
</cfoutput> | |
</table> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment