This content has been marked as final. Show 3 replies
I assume you will have a query to return the sponsor's page list ?
Let's assume that the column that contains the list is call "sponsor_list", then
<!--- the page we need to check against --->
<cfset onPage = 1>
<cfif ListGetAt(qry_sponsor_page.sponsor_list, onPage) Eq "true">
The value is true display the sponsor...
Are you able to make changes to the database where this is being stored? The trouble with saving your data in lists is that its slow to access, complex (as you're discovering) and doesn't give a lot of flexibility when you want to make changes (ie. add or remove a page from the list).
If you can change the database, I'd suggest creating a separate table for storing the sponsor's selections so you can then get all your information with just one or two simple queries. Presumably the Sponsor and Page tables have a unique ID field? If they don't then you might want to consider creating them. Once you have two tables with unique ID's it becomes very easy to create a third table to store related data - see below:
Page/Sponsor Table (new table):
- DisplayFlag (boolean)
With tables similar to above, you can select sponsors for any page with a simple query:
WHERE DisplayFlag = true
AND PageID = #url.pageID#
You can expand on this and include joins to the other tables to include the page and sponsor names and other details, the query above is a good starting point.
To paraphrase efecto, normalize your database and you won't have problems like this.