Copy link to clipboard
Copied
hi here is my code
help.cfm:
<script src="jquery.js"></script>
<script type="text/javascript">
$('#search').bind('keyup',updateQuery);
function updateQuery(){
$('#userlist').load('query.cfm?search='+ $('#search').val() );
}
$(document).ready(function(){
$('#userlist').load('query.cfm');
});
</script>
Search: <input id="search" type="text" />
<br />
<br />
<div id="userlist"></div>
query.cfm:
<cfparam name="search" type="string" default="">
<cfquery name="q" datasource="art">
SELECT LastName, FirstName
FROM artists
<cfif len(search)>
WHERE FirstName
LIKE <cfqueryparam cfsqltype="cf_sql_varchar" value="%#search#%" />
</cfif>
ORDER BY FirstName
</cfquery>
<cfoutput>#q.recordCount# User(s) Found</cfoutput>
<br />
<br />
<cfoutput query="q"> <a href="##" style="color: blue;"> #FirstName# </a><br />
</cfoutput>
this is my code but when i enter some thing in search box ia m not getting exact result and it is displaying all the records and not what i need.
will some one will help me in this
Thanks.
this is result :
13 User(s) Found
Aiden
Anthony
Diane
Elicia
Ellery
Emma
Jeff
Lori
Maxwell
Paul
Raquel
Taylor Webb
Viata
Copy link to clipboard
Copied
Your problem might be here.
<cfif len(search)>
I troubleshoot if/else problems like this.
if something
yes
else
no
display what that something actually is.