Skip to content

Instantly share code, notes, and snippets.

@rodionbykov
Last active December 28, 2016 13:43
Show Gist options
  • Save rodionbykov/7da2eec2cdad1be7d6e1f7bade7562d2 to your computer and use it in GitHub Desktop.
Save rodionbykov/7da2eec2cdad1be7d6e1f7bade7562d2 to your computer and use it in GitHub Desktop.
cf-101-cfquery-cfoutput-filter
<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