2 Replies Latest reply on Feb 12, 2007 2:10 PM by insuractive

    Last 25 rows ascending (breadcrumb)

    Coach707
      I am trying to get my page to disply the last 25 ROWS of a table in an ascending order.
      I can get the last 25 rows using MAXROW="25". ORDER BY DESC.

      I was then trying to reverse the ORDER of the call using a 2nd CFQUERY.. Arghhhh!
      Is there a cleaner way or any way to get the last 25 rows to show in a breadcrumb fashion?

      P.S. I would also like to be able to click <<previous 25>> and <<next 25>>, But this is a secondary issue.

      Thanks Alan


      storing an id for each entry, I am also storing #client.cftoken#..
        • 1. Re: Last 25 rows ascending (breadcrumb)
          Dan Bracuk Level 5
          the bottom 25 in ascending order is the same as the top 25 in descending order. Most dbs have a way of getting the top n records, but the method is db specific.
          • 2. Re: Last 25 rows ascending (breadcrumb)
            insuractive Level 3
            Ray Camden has a good article on Pagination (displaying one "page" of content at a time):

            http://ray.camdenfamily.com/index.cfm/2006/4/24/ColdFusion-and-Pagination

            The <cfoutput> tag allows you to specify a starting row and a maximum number of rows to display, so the number of records returned can be controlled in your <cfoutput> block.

            A better design for your code would be to retrieve one of your two queries from your datasource (e.g. populate1), then perform a Query of a Query in coldfusion to create another recordset in ascending order

            i.e.:

            1) use <cfquery datasource="#Application.u_load_tokens#"> to retrieve populate1
            2) Perform a query of a query to get a new query (populate2) that is really just populate1 in a different order
            3) Limit the number of records and control page forward/back in your <cfoutput> block.

            Hope that helps!