cfqueryparam- how to use cfqueryparam in cfquery tag

cfqueryparam

Usingcfqueryparam.cfm



<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>cfqueryparam- how to use cfqueryparam in cfquery tag</title>
</head>

<body>
<h2 style="color:DarkBlue; font-style:italic">ColdFusion cfqueryparam tag example: how to use cfqueryparam</h2>
<hr width="600" align="left" color="PowderBlue" />
<br />


<cfparam name="url.BookID" default="0">

<cfquery name="Books" datasource="cfbookclub">
 select BookID, Title from Books
    where BookID = <cfqueryparam value="#url.BookID#" cfsqltype="cf_sql_integer">
</cfquery>

<div style="font-family:'Courier New', Courier, monospace; font-size:large;">
    <a href="Usingcfqueryparam.cfm?BookID=1">Book ID = 1</a> <br />
    <a href="Usingcfqueryparam.cfm?BookID=2">Book ID = 2</a> <br />
    <a href="Usingcfqueryparam.cfm?BookID=3">Book ID = 3</a> <br />
    <a href="Usingcfqueryparam.cfm?BookID=4">Book ID = 4</a> <br />
</div>
<br />

<table border="0" cellpadding="2" cellspacing="2" bgcolor="OrangeRed" width="350">
 <tr style="background-color:DeepPink; color:Snow; font-weight:bold;">
     <td>
   Book ID        
        </td>
     <td>
         Title
        </td>
    </tr>
 <cfoutput query="Books">
        <tr style="color:Snow; background-color:HotPink; font-family:'Courier New', Courier, monospace;">
            <td>
                #BookID#        
            </td>
            <td>
                #Title#
            </td>
        </tr>
    </cfoutput>
</table>

</body>
</html>














More ColdFusion tutorials