Get ready for BLACK FRIDAY shopping starting in

Forums

ASP

This topic is locked

Advanced Results Page

Posted 27 Feb 2004 13:19:40
1
has voted
27 Feb 2004 13:19:40 Daniel Brown posted:
Hi there!

I have been pondering this problem for some time now, and decided I'm not likely to work it out for myself!

The site is an accommodation site I run for the local area.

I have a recordset that joins two database tables - one is a table of listings (eg titles, descriptions etc for cottages and hotels) the other is special offers. Entries in the special offers table have a unique key, as well as the field "lId" assigned to them, which matches the "lId" field for the listings.

The search results page returns 10 results at a time from the listings table, and what I want to do on the search results page for each result is to show a link to the Special Offers page ONLY if there are any special offers for that listing. It is like a conditional region that is shown only if the recordset is not empty - I'm just not sure how to do this several times on the same page!

Hope this all makes sense!!! Any questions, let me know - all help will be VERY gratefully received!!!!

Thanks,

Dan

Replies

Replied 29 Feb 2004 02:22:08
29 Feb 2004 02:22:08 Phil Shevlin replied:
I am assuming that your joined RS looks like:

lID | HotelName | Description | SpecialOfferID

Where ever you want the link just do a conditional statement:

if (rs("specialOfferID" <> "" then
response.write("<a href="offer.asp?offerID=""" & rs("specialOfferID" & """>See Offer</a>"
end if
Replied 01 Mar 2004 13:49:37
01 Mar 2004 13:49:37 Daniel Brown replied:
Hi,

Thanks for the advice - the problem I am now having is that the recordset is only selecting listings which have special offers associated with them - how do I get round this problem, so that even if a listing has no corresponding record(s) in the special offers table, it is still returned in the recordset?

Thanks,

Dan
Replied 01 Mar 2004 14:15:15
01 Mar 2004 14:15:15 Phil Shevlin replied:
To be exact, I would have to see your select statement. However, try using LEFT JOIN or RIGHT JOIN instead of just JOIN. (One of them should work for you)

Replied 01 Mar 2004 16:52:49
01 Mar 2004 16:52:49 Daniel Brown replied:
Thanks so much!!!! Its all working now!!!!

Reply to this topic