Opening links on Cfm pages

New Here ,
Sep 26, 2018 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

294

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
community guidelines
LEGEND ,
Sep 26, 2018 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
community guidelines
New Here ,
Sep 26, 2018 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
community guidelines
LEGEND ,
Sep 26, 2018 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
community guidelines
New Here ,
Sep 26, 2018 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
community guidelines
LEGEND ,
Sep 26, 2018 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
community guidelines
New Here ,
Sep 26, 2018 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
community guidelines
New Here ,
Sep 26, 2018 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
community guidelines
LEGEND ,
Sep 26, 2018 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
community guidelines
LEGEND ,
Sep 26, 2018 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
community guidelines
New Here ,
Sep 26, 2018 Sep 26, 2018

Copy link to clipboard

Copied

So terribly sorry.

This is exactly what I have

<cfquery datasource="source" name="rsname">

        SELECT        ID,Title, Date,

        FROM      dbo.qry_some_query    

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

    </cfquery>

        <cfoutput query="rsname">

            <div>

                            #Title#, #Date#

            </div>

        </cfoutput>

Still getting

Element ID is undefined in URL. 

and this is the same datasource as the first page so I know the datasource is working,and I do have an ID field name ID.

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
community guidelines
LEGEND ,
Sep 26, 2018 Sep 26, 2018

Copy link to clipboard

Copied

Do you have a link that I can view your project?

Could you copy/paste code, here (remember to use syntax highlighting), so we can see exactly what you're doing and in what order?

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
community guidelines
New Here ,
Sep 26, 2018 Sep 26, 2018

Copy link to clipboard

Copied

Working internally, no links. Sorry about the highlights, cannot figure that out.

My search page

<cfquery datasource="Stars" name="rsrecords">

        SELECT        ID, Title, Date,

        FROM      dbo.qry_prquery

        WHERE PA LIKE '%#text#%' OR Sec LIKE '%#text#% ( this isn't code, I will change it after everything works)

    </cfquery>

        <cfoutput query="rsrecords">

            <div>

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

            </div>

        </cfoutput>

The Link Page

<cfquery datasource="Stars" name="rsrec">

        SELECT        ID,Title, Date,

        FROM      dbo.qry_prquery   

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

    </cfquery>

        <cfoutput query="rsrec">

            <div>

                            #Title#, #Date#

            </div>

        </cfoutput>

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
community guidelines
LEGEND ,
Sep 26, 2018 Sep 26, 2018

Copy link to clipboard

Copied

Syntax highlighting cannot be done if you just click "reply", but if you click on "Use advanced editor" in the upper right of the dialogue, it will bring you to the editor that has syntax highlighting.  Just type/paste your code in the body, leaving a few spaces above and below it, then use your cursor to highlight it; then in the top of the editor look for  >>  and click it.  Choose "Syntax highlighting", then a style (I usually use "Java") and your code will be transformed into a neat little more easily readable blockquote.  (Hint - edits inside syntax highlighted code are difficult, near impossible.  Don't try it.)

The code you posted all looks good.  If you are still getting the "ID is undefined in URL" message, then the issue has to be that the file isn't making it to the server after you save it.  Check your logs.  There's a chance that the file on the server is set to read only, or something like that.  OR, make sure that you're saving it to the correct folder on the server (I've done that mistake many, many times.. ever after almost 20 years.)

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
community guidelines
New Here ,
Sep 26, 2018 Sep 26, 2018

Copy link to clipboard

Copied

after closing browsers and try again everything works. Thanks and have a wonderful day.

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
community guidelines
LEGEND ,
Sep 26, 2018 Sep 26, 2018

Copy link to clipboard

Copied

LATEST

Glad to hear it.  Didn't even think of mentioning CTRL-F5 to refresh the cache.

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
community guidelines