Go Back   CodingForums.com > :: Server side development > Other server side languages/ issues > ColdFusion

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-04-2011, 11:41 PM   PM User | #1
vivE
New to the CF scene

 
Join Date: Mar 2010
Posts: 8
Thanks: 1
Thanked 0 Times in 0 Posts
vivE is an unknown quantity at this point
URL parameter issue

Below #name# displays the correct information from the gather table.

For instance, if pearl is logged in with users.userID = 5, then #name# displays mek, tiff which is correct.

But,in the a href, display_graphic2.cfm?userID=5 for both mek and tiff. And I need it to equal the userID that is in the users table so clicking on mek would link to: display_graphic2.cfm?userID=4 and tiff would link to: display_graphic2.cfm?userID=3

How can I do this?

gather table data

gatherID name

3 pearl
5 mek
5 tiff
6 sammy

users table data

userID name

3 tiff
5 pearl
6 vi
4 meka
...

Code:
<cfquery name="matches" datasource="gifts">
SELECT gather.name, gather.gatherID, users.userID
FROM gather INNER JOIN users 
ON gather.gatherID=users.userID
WHERE gather.gatherID=<cfqueryparam cfsqltype="cf_sql_integer" value="#session.userID#">

</cfquery>

See: <cfoutput query="matches"><a href="display_graphic2.cfm?userID=#userID#">#name#</a>,

</cfoutput>
SOLVED.
changed my query to JOIN on name not ID:
SELECT gather.gatherID, gather.name, users.userID
FROM gather INNER JOIN users ON gather.name=users.name
WHERE gatherID=<cfqueryparam cfsqltype="cf_sql_integer" value="#session.userID#">

Last edited by vivE; 07-05-2011 at 10:48 PM.. Reason: fixed this
vivE is offline   Reply With Quote
Old 08-16-2011, 02:16 AM   PM User | #2
FuquayDentist
New Coder

 
Join Date: Aug 2011
Location: Fuquay Varina NC
Posts: 21
Thanks: 1
Thanked 2 Times in 2 Posts
FuquayDentist is an unknown quantity at this point
loop through the output of the query until you find the matching record and then <cfoutput> the variable and exit the loop.
FuquayDentist is offline   Reply With Quote
Old 08-16-2011, 02:19 AM   PM User | #3
FuquayDentist
New Coder

 
Join Date: Aug 2011
Location: Fuquay Varina NC
Posts: 21
Thanks: 1
Thanked 2 Times in 2 Posts
FuquayDentist is an unknown quantity at this point
ok hey looks like you've solved it with the query / joins. Cool. that's a little slicker than my method, but it goes to show there are multiple ways to get stuff done.
FuquayDentist is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:55 AM.


Advertisement
Log in to turn off these ads.