Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

priority search result

Status
Not open for further replies.

maximos

Technical User
Sep 27, 2002
109
CA
Hello everyone, i'm kind of a newbie to cf,

i've created a directory web site and its working just fine, but what i want is , when a user search for a name i want to have the names that are queried to be displayed in a priorty , and the top 3 results to be bolded,

Any help or where i could get resource, i'll be greatly apreciated,

Max Tadros
 
Some assumptions:
[ul]
[li]The user enters the name into a form field, and clicks "submit"[/li]
[li]The form that the user enters the name(s) into uses method="post"[/li]
[li]The page that the form submits to runs some type of query based on the value that the user enters[/li]
[/ul]

So, say the form field that the user enters the name into is called searchname

And you're already doing your query based off of that value. Something like:
Code:
  <CFQUERY name=&quot;qryNameSearch&quot; ...>
      SELECT *
        FROM tablename
       WHERE name LIKE '%#FORM.searchname#%'
  </CFQUERY>
or whatever.

As you're outputing the results:
Code:
<CFOUTPUT query=&quot;qryNameSearch&quot;>
  <CFIF Compare(qryNameSearch.name,FORM.searchname) EQ 0 OR qryNameSearch.CurrentRow LTE 3>
     <b>#qryNameSearch.name#</b>
  <CFELSE>
     #qryNameSearch.name#
  </CFIF>
</CFOUTPUT>


-Carl
 

Thanks Carl, i tried to insert that cfif statment but i got an some erros, see, i had some cfif statment already in the cfquery tag already, i'm not sure if that will interfeare with the way its outputed, here is the codes , <

Thanks again

<cfquery name=&quot;qItems&quot; dataSource=&quot;adirectory&quot;>
SELECT * FROM tblCategories, tblItems
WHERE tblCategories.CategoryID = tblItems.CategoryIDFK


<cfif CategoryID NEQ &quot;ALL&quot;>
and tblItems.CategoryIDFK = '#FORM.categoryID#'
</cfif>

<cfif BusinessDescription NEQ &quot;&quot;>
and tblItems.BusinessDescription Like'%M.BusinessDescription#%'
</cfif>


<cfif CompanyName NEQ &quot;&quot;>
and tblItems.CompanyName Like'%#FORM.CompanyName#%'
</cfif>

<cfif City NEQ &quot;All&quot;>
and tblItems.City Like'%#FORM.City#%'
</cfif>



</cfquery>

<cfoutput query=&quot;qItems&quot; startRow=&quot;#FromRec#&quot; splayCount#&quot;>
<CFIF Compare (tblCategories.CategoryID ,tblItems.CategoryIDFK) EQ 0 OR qItems.CurrentRow LTE 3>
<b>#tblItems.CategoryIDFK#</b>
<CFELSE>
#tblItems.CategoryIDFK#
</CFIF>

<tr bgcolor=&quot;##CCCCCC&quot;>
<td colspan=&quot;5&quot;><hr></td>
</tr>
<tr>
<td><a href=&quot;detail.cfm?ContactID=#ContactID#&quot; >#CompanyName#</a></td>
<td>&nbsp;</td>
<td>#qItems.Address#</td>
<td>&nbsp;</td>
<td>#qItems.City# </td>
</tr>
</CFOUTPUT>
 
What sorts of errors are you getting?

The CFIF statements inside your CFQUERY look fine (except for a few typos that I attribute to cut-and-paste... like &quot;%M.BusinessDescription#%&quot; was probably meant to be &quot;%#FORM.BusinessDescription#%&quot;.

The if statements I suggested would, indeed, go within the CFOUTPUT block where you have them. The only problem there I see is that you're outputing the #tblItems.CategoryIDFK#
outside of a table row... so it's probably not going to display (or, at least, not display where you expect) in the browser.

Other than that... I'm not sure what the &quot;splayCount#&quot; is all about. That would obviously break... but, again, not sure if that's just cut-and-paste, or ... ?



-Carl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top