2 Replies - 3901 Views - Last Post: 05 July 2011 - 02:56 PM Rate Topic: -----

#1 via  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 07-March 08

URL parameter passing problem

Posted 05 July 2011 - 07:26 AM

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>


Is This A Good Question/Topic? 0
  • +

Replies To: URL parameter passing problem

#2 Craig328  Icon User is offline

  • I make this look good
  • member icon

Reputation: 1546
  • View blog
  • Posts: 2,990
  • Joined: 13-January 08

Re: URL parameter passing problem

Posted 05 July 2011 - 07:43 AM

Hi via and welcome to DIC!

The problem you're having looks to be on your INNER JOIN in your query:

INNER JOIN users ON gather.gatherID = users.userID


You're using the id value from gather (gatherid). This means when you're logged in with userID 5 (per your WHERE statement) you're telling your query to pull in all user records where the userID is equal to the gatherID...and in your WHERE statement you've declared that all gatherIDs will equal 5. So, the only value for gatherID that your query will return, when using a session.userID value of 5, will be 5.

Basically, your issue is in the logic of your query statement.

Good luck!

This post has been edited by Craig328: 05 July 2011 - 07:44 AM

Was This Post Helpful? 1
  • +
  • -

#3 via  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 07-March 08

Re: URL parameter passing problem

Posted 05 July 2011 - 02:56 PM

Thank you for pointing this out...I needed to join on name not id.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1