Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

URL Parameter passing problem

New Here ,
Jul 05, 2011 Jul 05, 2011

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:
<!--- find users based on match with loggin in user --->
<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> <!--- display logged in users matches and pass matched user userID in URL ---> See: <cfoutput query="matches">
          <a href="display_graphic2.cfm?userID=#userID#">#name#</a>,      </cfoutput>
868
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Contributor , Jul 05, 2011 Jul 05, 2011

Not sure what the question is. In that data with that SQL statement,

userID and gatherID will always be the same, since it's an INNER JOIN on

gatherID = userID, so those IDs of 3 and 4 will never exist in the query,

only 5. It looks like you need to be joining on name, not ID:

That would get you userID '3' for 'tiff' and userID '4' for 'mek' (assuming

that 'meka' is a typo in the users table).

Translate
LEGEND ,
Jul 05, 2011 Jul 05, 2011

When in doubt, look at your data.

First, after you run your query, cfdump the recordset and see if it's what you expect.

Next, in your cfoutput block, change this

<a href="display_graphic2.cfm?userID=#userID#">#name#</a>,

to this

<a href="display_graphic2.cfm?userID=#userID#">User ID is #userID# and name is #name#</a>,

and see if it's what you expect

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 05, 2011 Jul 05, 2011

Thank you... this was very helpful.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jul 05, 2011 Jul 05, 2011

Not sure what the question is. In that data with that SQL statement,

userID and gatherID will always be the same, since it's an INNER JOIN on

gatherID = userID, so those IDs of 3 and 4 will never exist in the query,

only 5. It looks like you need to be joining on name, not ID:

That would get you userID '3' for 'tiff' and userID '4' for 'mek' (assuming

that 'meka' is a typo in the users table).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 05, 2011 Jul 05, 2011
LATEST

Thank you. yes, I needed to join on name not id.

That fixed it. I really appreciate your help.

Sincerely.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources