There are many ways to do this.  Try this code:

Additional Query:

<cfquery name="searchProducts">
  SELECT *
  FROM products
  WHERE productname LIKE '%#Form.search#%'
</cfquery>

Same 1st Search Query:

<cfquery name="search">
  SELECT *
  FROM dolls
  WHERE name LIKE '%#Form.search#%'
</cfquery>

Display Results:

<cfif searchProducts.RecordCount GT 0>

<h2>Products</h2>      

            

<!-- Display Product results -->
<cfoutput query="searchProducts">
<a href="" productname
#</a><br>
</cfoutput>

</cfif>

<cfif search.RecordCount GT 0>

<h2>Dolls</h2>            

            

<!-- Display Product results -->
<cfoutput query="search">
<a href=""> </cfoutput>

</cfif>

Ryan Duckworth
Macromedia ColdFusion Certified Professional
Uhlig Communications
10983 Granada Lane
Overland Park, KS 66211
(913) 754-4272

  _____  

From: Donna French [mailto:[EMAIL PROTECTED]
Sent: Monday, August 02, 2004 2:42 PM
To: CF-Talk
Subject: Search 2 tables

Okay, I must warn you all that when I first built this web app I was a
TOTAL newbie and had no idea what I was doing with CF or database
design.

With that said, I am attempting to patch the search feature so that it
can pull results from 2 tables while I redesign the app and database.

The current code is:

<cfquery name="search">
  SELECT *
  FROM dolls
  WHERE name LIKE '%#Form.search#%'
</cfquery>

<!-- Display results -->
<cfoutput query="search">
<a href=""> </cfoutput>

The problem is that I need to search 2 tables and display results
accordingly.

Table 2 info-

products(table)
productid(pk)
lanesid(text)
productname(text)

If results are found in this table, the link will need to be:
detailsProduct.cfm?productid=#productid#

I think I've given enough information, and I won't bother to send all
the different methods I've tried to get this to work.

If you have ANY ideas please send!

Greatly appreciate all of your help and patience.

TIA,
Donna

  _____
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to