Highlighted

Opening links on Cfm pages

New Here ,
Sep 26, 2018

Copy link to clipboard

Copied

Playing a bit with CF.

I have a page that's working fine pulling info from MSSQL.

So for example if I do a search for 'Smith' it pulls all the Smiths as follows

Smith, R, DOB, Address, etc

I would like to have a link for each record pulled that the user clicks on to get more detailed information about that Smith.

How can I do this?

Thanks

Views

272

Likes

Translate

Translate

Report

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

Opening links on Cfm pages

New Here ,
Sep 26, 2018

Copy link to clipboard

Copied

Playing a bit with CF.

I have a page that's working fine pulling info from MSSQL.

So for example if I do a search for 'Smith' it pulls all the Smiths as follows

Smith, R, DOB, Address, etc

I would like to have a link for each record pulled that the user clicks on to get more detailed information about that Smith.

How can I do this?

Thanks

Views

273

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Sep 26, 2018 0
LEGEND ,
Sep 26, 2018

Copy link to clipboard

Copied

Typically, the records should have some kind of unique ID column that can be included in the query.  Then create a hyperlink that goes to another page including that UID as a URL parameter.  The new page would then query just one record using the UID as the identifier and display the recordset.

HTH,

^ _ ^

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 26, 2018 0
New Here ,
Sep 26, 2018

Copy link to clipboard

Copied

I kinda did that with the little knowledge I have but not getting anythere.

This is my first page that pulls the records

cfoutput query="Name">

            <div>

                #ID#, #Title#, #Date# <a href="link.cfm"> view </a>

            </div>

        </cfoutput>

Linked page

<cfquery datasource="Name" name="Name">

        SELECT        ID,Title, Date, DetailedInfo

        FROM      dbo.qry_some_query    

        WHERE ID=#URL.ID#

    </cfquery>

Thanks

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 26, 2018 0
LEGEND ,
Sep 26, 2018

Copy link to clipboard

Copied

I know that this is just pseudo-code, but are you actually including the ?ID=#ID# to the link href attribute?  You didn't indicate.

And I'm not trying to sound trite, but "but not getting anythere" isn't very descriptive.  Precisely what is not working?  Are you getting any error messages in the browser console?  Anything in the CF logs?

V/r,

^ _ ^

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 26, 2018 0
New Here ,
Sep 26, 2018

Copy link to clipboard

Copied

Not at all, you are more than welcome to yell at me, I am learning.

My second page gives "

Element ID is undefined in URL. 

No I didn't include the ID in the link, so I guess that is my question. How do I do that?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 26, 2018 0
LEGEND ,
Sep 26, 2018

Copy link to clipboard

Copied

<cfoutput query="Name">

            <div>

                #ID#, #Title#, #Date# <a href="link.cfm?ID=#ID#"> view </a>

            </div>

        </cfoutput>

The letters in red are URL parameters.  It starts with a question mark letting the browser know that everything after it is/are parameters for processing.

HTH,

^ _ ^

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 26, 2018 0
New Here ,
Sep 26, 2018

Copy link to clipboard

Copied

Awesome, thank you so much.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 26, 2018 0
New Here ,
Sep 26, 2018

Copy link to clipboard

Copied

Actually I jumped the gun.

How should I write the where clause in the linked page?

I currently have this WHERE ID=#url.ID#

and getting

Element ID is undefined in URL. 

Thanks

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 26, 2018 0
LEGEND ,
Sep 26, 2018

Copy link to clipboard

Copied

Are you sure you pushed the edit to the server and refreshed the browser?  Refresh the browser and do a View Source, locate the links and eyeball that the URL parameter "ID" is present.

V/r,

^ _ ^

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 26, 2018 0
LEGEND ,
Sep 26, 2018

Copy link to clipboard

Copied

Oh, and to answer your question:

<cfquery datasource="Name" name="Name">

        SELECT        ID,Title, Date, DetailedInfo

        FROM      dbo.qry_some_query    

        WHERE ID=<cfqueryparam value="#URL.ID#" />

    </cfquery>

HTH,

^ _ ^

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 26, 2018 0