Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Searching unrelated tables via join query / Linking to different "detail" pages depending on table particular result is from

Posted on 2007-03-23
10
180 Views
Last Modified: 2010-05-18
Hi!  I have a search engine on my site where I need to return results from several different tables that are NOT related.  This is a furniture site so i have a table for the actual furniture, available fabrics, top finishes and availabe trims.  The database is in MS Access so I wrote a query in access to join all 4 of the tables.  I then created a recordset in Dreamweaver to search that query and return the results through a repeat region.  That is working great.  Here is my problem...

Each item that comes up in the repeat region on the results page has a thumbnail image and a style number.  Each of these link to the "details" page for that particular ID.  That is working fine for the Furniture.  But when I click on a Finish, Fabric or Trim in the results page, it sends the right ID number but pulls the result from the Furniture Table.  What I need to do is have 4 separate detail pages (which I already have built) and go to them depending on which item is clicked.  How can I achieve this?  As the Query does not have any info as to the table name how can I differentiate between them?

Here is the link code that is on the thumbnail and style number for each item in the results page:

Detail.asp?<%= MM_keepNone & MM_joinChar(MM_keepNone) & "ID=" & rsFC.Fields.Item("SearchID").Value %>

Furniture results should be sent exactly as is but:
     - Fabric results should be sent to LargeFabric.asp instead of Detail.asp
     - Finish results should be sent to LargeFinish.asp
     - Trim results should be sent to LargeTrim.asp

Thanks,
Scott
0
Comment
Question by:aswhitehead
  • 2
  • 2
  • 2
  • +1
10 Comments
 
LVL 18

Expert Comment

by:mgfranz
ID: 18780409
How are you creating the <a href> tag?  Does it get built dynamically?  I would think a simple loop that creates the HREFs would be able to send the values to the correct page.  When the links are created just set the correct page and values.  Unless I'm missing somethign this is a pretty simple fix.
0
 
LVL 50

Expert Comment

by:Lowfatspread
ID: 18781324
if the query doesn't differentitate between the different data types then
you can't do anything ...

amend the query to indicate / include a reference to the type or page name...
0
 

Author Comment

by:aswhitehead
ID: 18781866
mgfranz,

Here is the code for the <a href> tag:
<a href="Detail.asp?<%= MM_keepNone & MM_joinChar(MM_keepNone) & "ID=" & rsFC.Fields.Item("SearchID").Value %>"><%=(rsFC.Fields.Item("SearchStyle").Value)%></a>

The "Detail.asp" is hardcoded into the page.

Scott
0
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 

Author Comment

by:aswhitehead
ID: 18781876
Lowfatspread:

So put a column in the query that designates the asp page to go to for each category?  How would I use that info to replace the Detail.asp in my <a href> tag?

Scott
0
 

Expert Comment

by:alicia1234
ID: 18781921
Could you just add something like & gotopage=1 to the query string? Where "1" would tell the receiving page to use "LargeFabric.asp", 2 would mean "LargeFinish.asp", and 3 would mean "LargeTrim.asp" ? Or am I oversimplifying or not understanding the problem?
0
 
LVL 18

Accepted Solution

by:
mgfranz earned 250 total points
ID: 18783692
You are either going to have to NOT hardcode the detail.asp part into the page or make some changes to your db.  My first thought would be to add a field called itemID, populate it with an ID # that matched either the fabric, trim, finish or furniture, such as 1, 2, 3 or 4.  That ID can be passed through the href so the details.asp page would know which other search page to Redirect to.  Then redo the HREF to look like this;

<a href="Detail.asp?<%= MM_keepNone & MM_joinChar(MM_keepNone) & "ID=" & rsFC.Fields.Item("SearchID").Value "& itemID="&rsFC("itemID")& %>"><%=(rsFC.Fields.Item("SearchStyle").Value)%></a>

Now in details.asp, just do a If..Then call for the itemID Redirect;

theID = Request("itemID")
mainID = Request("ID")
If theID = "1" Then
     Response.Redirect "LargeFabric.asp?ID="&mainID &"
ElseIf theID = "2" Then
     Response.Redirect "LargeFinish.asp?ID="&mainID &"
ElseIf theID = "3" Then
     Response.Redirect "Largetrim.asp?ID="&mainID &"
Else ' continue with the details.asp script
...
End If

End If

This way you can still pass the href values to a specific page based on the item ID you created in the db which specified which parameter needs to be searched.

BTW, I build furniture for fun and profit, I would love to see your site, care to share?
0
 
LVL 50

Assisted Solution

by:Lowfatspread
Lowfatspread earned 250 total points
ID: 18784576
return a page name from the query ...  much faster than putting the if into code on the page..

<a href=rsfc.fields.item("PageName")&"?<%= MM_keepNone & MM_joinChar(MM_keepNone) & "ID=" & rsFC.Fields.Item("SearchID").Value "& itemID="&rsFC("itemID")& %>"><%=(rsFC.Fields.Item("SearchStyle").Value)%></a>
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question