From: silstorm on
Not sure how best to achieve this without adding a further cfquery into the
page, which I'd like to avoid doing if possible.

I have a standard login page, which sets some session variables. However some
pages can also be viewed without logging in. One of these pages has a 'watch
list' feature, and I basically want to control how this is displayed as follows;

- User not logged in : Prompt to login if they want to add to watchlist
- User is logged in, but item is not on watch list : Prompt to add to watchlist
- User is logged in, and already has item on watchlist : Prompt to state item
is on watchlist

Functionality is basically very similar to the way 'My Ebay' works.

The watch list is currently being brought in via a header file, with the
following query;

<cfquery name="getwatchlist" datasource="#datasource#">
SELECT user_id, merchant_id
FROM cc_watchlists
WHERE user_id=#SESSION.Auth.ID#
</cfquery>

The output as it stands (which doesn't look for the item already being on the
watch list) is as follows;

<cfif IsDefined('SESSION.Auth.username')>
Add to watch list
<cfelse>
Please login to add to watch list</a>
</cfif>

My initial thought is that I should be looking to add an 'IN' statement for
the query, but that's about as far as I've managed to get (it's been a loooong
day!).

Any pointers gratefully received!

From: Dan Bracuk on
On the cold fusion side, the cfswitch and cfcase tags might be useful. Useage is described in the cfml reference manual. If you don't have one, the internet does.