| Posted By |
Discussion Topic: Dynamic Links
|
|
metaphiz |
12-18-2003 @ 1:44 PM |
|
|
Junior Member
Posts: 103
Joined: Dec 2002
|
I'm doing a DVD site and I want to load actor's names from the product table into the product page as dynamic links to all the other movies with that actor. If each actor were isolated in their own database field, I would just feed the actor name into a URL parameter and pass it through the link to a query template that takes the actor parameter and searches on it. But the DB field for actors contains many comma-delimited actors' names. How can I dynamically generate the link for each actor in this situation? Do I have to change the DB structure (adding tables or isolating actor names)?
gsnack kerouack kickin it in the back jack
|
CJ |
12-18-2003 @ 1:53 PM |
|
|
Administrator
Posts: 4262
Joined: Oct 2002
|
i would've preferred to see each actor in his/her own field with an actorID. if you can do that, i think it would be a stronger app. holding comma delimited lists in relational databases is terribly counterproductive. relational databases exist to prevent things like that. but if you MUST, i would loop over the field when outputting it...something like: <cfloop list="#queryname.actors#" index="i"> <a href="nextpage.cfm?actor=#URLEncodedFormat(i)#">#i#</a> </cfloop> Then on the next page you can do something like: <cfquery name="getActorsMovies" datasource="myDSN"> SELECT columns FROM table WHERE <cfqueryparam value="#URL.actor#" cfsqltype="cf_sql_char"> IN actorColumnName </cfquery> but i'd really really think about redoing the db structure before going that route
-CJ- @ #coldfusion/DALNet http://charlie.griefer.com
|
metaphiz |
12-18-2003 @ 4:24 PM |
|
|
Junior Member
Posts: 103
Joined: Dec 2002
|
Great. I hear what you are saying--it will be more powerful app if the DB is set up better. As a temporary 'band-aid' solution, I was able to get the code to work. thanks. One more question: how would I use the RemoveChars() function in combination with #URLEncodedFormat(Trim(i))# ? I'm trying it like #URLEncodedFormat(Trim(RemoveChars(i, 7,10))# and like #RemoveChars(URLEncodedFormat(Trim(i)),7,3)# and neither one works Quasi-Suave Digital--Crucial Deviations
This message was edited by metaphiz on 12-18-03 @ 4:27 PM
|
CJ |
12-18-2003 @ 4:45 PM |
|
|
Administrator
Posts: 4262
Joined: Oct 2002
|
what exactly is it that you're trying to do??
-CJ- @ #coldfusion/DALNet http://charlie.griefer.com
|
metaphiz |
12-18-2003 @ 4:56 PM |
|
|
Junior Member
Posts: 103
Joined: Dec 2002
|
The database field that comes comma delimited also has some extra characters and white space. The extra characters are always: actors:;;; so it goes: actors:;;;Tom Cruise, Snoop Doggy Dogg, Angela Lansbury I want it to just say: actors: Tom Cruise, Snoop Doggy Dogg, Angela Lansbury Quasi-Suave Digital--Crucial Deviations
This message was edited by metaphiz on 12-18-03 @ 5:03 PM
|
CJ |
12-18-2003 @ 5:55 PM |
|
|
Administrator
Posts: 4262
Joined: Oct 2002
|
wow. I *really* don't like this database setup. so the value of the column is actors:;;;Tom Cruise, Snoop Doggy Dogg, Angela Lansbury? why would you have 'actors:;;;' as part of the value?
-CJ- @ #coldfusion/DALNet http://charlie.griefer.com
|
metaphiz |
12-19-2003 @ 10:49 AM |
|
|
Junior Member
Posts: 103
Joined: Dec 2002
|
We're using an ecommerce package that inserts the 'actors:;;;' text into the db. It then uses the tripple semicolon to identify the heading when it outputs it. Not the best system but it's what I'm working with. As it is, i need to eliminate the semicolons when i retrieve the field.
Quasi-Suave Digital--Crucial Deviations
|