Skip navigation
Currently Being Moderated

Need help linking from static page to db record

May 4, 2010 1:55 PM

I'm having trouble linking from an ordinary <a href="description.cfm?recordid=A51">Select</a> link to an action page with an SQL query of

 

select * from classes where recordid="....." I don't know what to put in here.

 

I've tried '#rsClasses.recordid#' but that just gives me the first record in the database. What I want to bring in is the A25 that I've identified in the link. I have about 30 links I'd like to identify myself rather than do a database search for them. In an order version of Dreamweaver I was able to make that static link connection using a parameter like: <cfparam name="rsOperas_TM_progid" default="#progid#"> with a query of <cfquery name="rsOperas" datasource="#MM-cnOne_DSN#"> SELECT * from operas WHERE progid = #rsOperas_TM_progid# </cfquery> Everything worked fine then but I can't get it to work with my new page. What should I be putting in my original select statement? I can't just use URL.recordid because I don't want to do a search. I want to link directly.

Thanks.

 
Replies
  • Currently Being Moderated
    May 4, 2010 2:16 PM   in reply to tharring

    #url.recordID#

     

    <cfqueryparam value="#url.recordID#" cfsqltype="cf_sql_intenger"> would be even better.

     
    |
    Mark as:
  • Currently Being Moderated
    May 4, 2010 3:23 PM   in reply to tharring

    <cfqueryparam....> is not a block tag, it does not need a closing </cfqueryparam> tag.  I don't know if this would cause an error, I've never tried to do that.

     

    Then just use the proper cf_sql... type.  I.E "cf_sql_char" or "cf_sql_varchar" or something.  See the documentation for the full list.

     
    |
    Mark as:
  • Currently Being Moderated
    May 4, 2010 4:44 PM   in reply to tharring

    Use the syntax Ian suggested in his first reply.

     
    |
    Mark as:
  • Currently Being Moderated
    May 5, 2010 7:53 AM   in reply to tharring

    The non-existant <cfqueryparam....> tag, found in about three seconds with this internet search: [http://www.google.com/search?q=cfqueryparam]

     

    http://livedocs.adobe.com/coldfusion/8/htmldocs/Tags_p-q_18.html

    cfqueryparam

     

    #Description

    Verifies the data type of a query parameter and, for DBMSs that  support bind variables, enables ColdFusion to use bind variables in the  SQL statement. Bind variable usage enhances performance when executing a  cfquery statement multiple times.

     

    This  tag is nested within a cfquery tag,  embedded in a query SQL statement. If you specify optional parameters,  this tag performs data validation.

     

    Adobe recommends that you use  the cfqueryparam tag within every cfquery tag, to help secure your databases from  unauthorized users. For more information, see Security Bulletin  ASB99-04, "Multiple SQL Statements in Dynamic Queries," at www.adobe.com/devnet/security/security_zone/asb99-04.html,  and "Accessing  and Retrieving Data" in the ColdFusion Developer's Guide.

     

    Category

    Database  manipulation tags

    #Syntax

    <cfquery 
        name = "query name"
        dataSource = "data source name"
        ...other attributes...
        SQL STATEMENT column_name =
        <cfqueryparam value = "parameter value"
            CFSQLType = "parameter type"
            list = "yes|no"
            maxLength = "maximum parameter length"
            null = "yes|no"
            scale = "number of decimal places"
            separator = "separator character">
        AND/OR ...additional criteria of the WHERE clause...>
    </cfquery>

     

     

    Note that there is no closing tag in the <cfquerparam...> syntax sample.

     
    |
    Mark as:
  • Currently Being Moderated
    May 5, 2010 7:20 AM   in reply to tharring

    Additionally, if you use <cfqueryparam> (which you definitely should) I don't think you'd even need the single quotes.  The tag formats it for you.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points