Specifying number of rows in a CFLOOP query

Good morning everyone...I have a question/problem which I hope is simple but I'm having a hard time coming up with a solution., I have a simple query, and that query will return several rows of information about a specific project. Each row has a specific id number. I can display the query results using CFLOOP and everything works fine. But what I want to do is a) only show three records (the last three entered) instead of every records and then b) have a button or link where the user can select to show the remaining records. My query is below:

<CFQUERY DATASOURCE="MCA_Oracle" NAME="GetExcludeCurDocCommentList">
 SELECT UNOB_REMARKS.*
 FROM MCA.UNOB_REMARKS
 WHERE UNOB_REMARKS.MIPR_ID = '#SESSION.urlpass.MIPR_ID#'
 ORDER BY UNOB_REMARKS.LAST_REMARK_UPDATE DESC
 </CFQUERY>

and then all I'm doing with the CFLOOP is:

<TABLE>


<CFLOOP query="GetExcludeCurDocCommentList">
<TR>
<TD><CFINPUT TYPE="Text"
                     NAME="Exs_DATE"
                     VALUE="#DateFormat(GetExcludeCurDocCommentList.LAST_REMARK_UPDATE,'mm/dd/yyyy')#"
                     SIZE="12"
                     MAXLENGTH="25"
                     style="border-color:WHITE; border-width:2; background-color:D1D0CE" readonly="Yes"></TD>

<TD><textarea rows="2" cols="73" name="Exs_Remark" style="border-color:WHITE; border-width:2; background-color:D1D0CE" readonly>#GetExcludeCurDocCommentList.REMARKS#</textarea></TD>

<TD><CFINPUT TYPE="Text"
                     NAME="Exs_ID"
                     VALUE="#GetExcludeCurDocCommentList.ID#"
                     SIZE="5"
                     MAXLENGTH="25"
                     style="border-color:WHITE; border-width:2; background-color:D1D0CE" readonly="Yes"></TD>
</tr></CFLOOP></TABLE>

Any help would be greatly appreciated!!!
diecasthft01Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gdemariaCommented:
You could set a "TOP X" on your select to show just the three records.

Then the button will redraw the screen with a new number for the maxRows value

<cfparam name="url.maxRows" default="3">

<CFQUERY DATASOURCE="MCA_Oracle" NAME="GetExcludeCurDocCommentList">
 SELECT top #maxRows# UNOB_REMARKS.*
 FROM MCA.UNOB_REMARKS
 WHERE UNOB_REMARKS.MIPR_ID = '#SESSION.urlpass.MIPR_ID#'
 ORDER BY UNOB_REMARKS.LAST_REMARK_UPDATE DESC
</CFQUERY>


<a href="xxxx?maxRows=9999">Show All</a>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
diecasthft01Author Commented:
That's perfect. That works exactly as I want it to. Thanks a lot!!!
0
_agx_Commented:
Don't forget to wrap it in a val() to protect against sql injection , ie val(url.maxRows)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ColdFusion Language

From novice to tech pro — start learning today.