Solved

page count

Posted on 2002-04-29
14
172 Views
Last Modified: 2013-12-24
how can I add a page count to the results of my query?

ie page 1 of 5

my query returns a recordset that could be realy large however I am printing this from the browser and am forcing the page to break every 29 lines using
<style media="print">
BR.pageBreak { page-break-after: always }
</style>
on the pages I would like to get a page count ie page 1 of 5 depending on how many records are displayed.

this is what I have been able to come up with, with alot of assistance?


<cfset numberOfRecordsBeforeHeaderDisplay = 36>
<cfoutput query="FPRDUE">


 <cfif FPRDUE.currentRow mod numberOfRecordsBeforeHeaderDisplay EQ 1>
  <table width="100%" cellpadding="0" cellspacing="0">
  <tr>
      <td width="100%" align="center" valign="top"><font face="Arial, Helvetica, sans-serif" size="5"><b><i>FULL
        PAYMENT REQUIRED <BR>
        PAYMENTS OVER DUE </i></b></font></td>
    </tr>
     <tr><td><b>#dateformat(now(),"dddd, mmmm dd, yyyy")#</b></td></tr></table>  
  <table width="100%" border="1" bordercolor="##000000" cellpadding="0" cellspacing="0">
    <tr>
      <td ><font face="Arial, Helvetica, sans-serif" size="2">Exhibitor
        Number</font></td>
      <td><font face="Arial, Helvetica, sans-serif" size="2">Company
        Name</font></td>
      <td ><font face="Arial, Helvetica, sans-serif" size="2">FPR Date</font></td>
      <td ><font face="Arial, Helvetica, sans-serif" size="2">Contract
        Date</font></td>
      <td width="13%">Booth Number</td>
      <td width="19%">Total Cost</td>
    </tr>
    <td >
    <td>
     </cfif>

    <tr>
      <td><font face="Arial, Helvetica, sans-serif" size="2">#exhibitornumber#</font></td>
      <td ><font face="Arial, Helvetica, sans-serif" size="2">#EX_co_Name#</font></td>
      <td><font face="Arial, Helvetica, sans-serif" size="2">#Dateformat(BT_FPRDate,"mm/dd/YY")#</font></td>
      <td><font face="Arial, Helvetica, sans-serif" size="2">#dateformat(bt_contractdate,"mm/dd/yy")#</font></td>
      <td>#bt_booth1#</td>
      <td>#dollarformat(BT_TotalCost)#</td>
    </tr>
    <!--- Display close table --->
    <td width="11%">
     <cfif FPRDUE.currentRow mod numberOfRecordsBeforeHeaderDisplay EQ 0 OR FPRDUE.currentRow EQ
FPRDUE.recordCount>
  </table>
  <br class="pageBreak">
 </cfif>
</cfoutput>
0
Comment
Question by:jriver12
  • 8
  • 3
  • 2
  • +1
14 Comments
 
LVL 11

Expert Comment

by:jimmy282
Comment Utility
go here
http://devex.macromedia.com/developer/gallery

and search for cf_nextpage

Its exactly what u want.

Jimmy
0
 

Expert Comment

by:bing2x
Comment Utility
Try my script here...

<cfoutput>
<cfif CurrentPos gt qAnalysisRule.RecordCount><cfset CurrentPos = Ceiling(qAnalysisRule.RecordCount/varMaxRows)></cfif>
<cfset varEndPos = CurrentPos + varMaxRows - 1>
<cfif varEndPos gt qAnalysisRule.RecordCount><cfset varEndPos = qAnalysisRule.RecordCount></cfif>
<cfset CurrentPage = Ceiling(CurrentPos/varMaxRows)>
<cfset TotalPage = Ceiling(qAnalysisRule.RecordCount/varMaxRows)>

         
<form name="frmPage" action="#CGI.SCRIPT_NAME#?#CGI.QUERY_STRING#" method="post">
     <select OnChange="document.frmPage.submit();">
          <cfif qAnalysisRule.RecordCount eq 0><option value="0">0</cfif>
          <cfloop index="i" from="1" to="#TotalPage#"><option value="#i#"<cfif i eq CurrentPage> selected</cfif>>#i#</cfloop>
     </select>

     <cfloop query="qResult" startrow="#CurrentPos#" endrow="#varEndPos#">
     #rule_id#<br>
     </cfloop>
     <input type="hidden" name="CurrentPos" value="#CurrentPos#">
</form>
</cfoutput>
0
 

Author Comment

by:jriver12
Comment Utility
bing2x

What is the need for the form?
0
 

Expert Comment

by:bing2x
Comment Utility
used for the "NEXT PAGE" or "PREVIOUS PAGE"
0
 

Author Comment

by:jriver12
Comment Utility
sorry,
it isn't pagination that I am looking for.

what I am trying to do is to have cf count the page breaks in my page and then on every page have it show what page it is on ie page 1 of ??

the pages are displayed in the browser as one continuous page.

you had a solution that I have not been able to replicate on my current code.  it was the solution on http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=coldfusion&qid=20292333.

maybe that would give you a better Idea of what I am trying to accomplish.
0
 

Author Comment

by:jriver12
Comment Utility
bing2x,
this is a code that you had previously helpd me with:

<style media="print">
BR.pageBreak { page-break-after: always }
</style>

and just put <br class="pageBreak"> on the line that you want to make it seperate from the first page...

Coding Example :
<cfoutput>
<cfset count = 0>
<cfloop from="1" to="2" index="i">
Page #i#
------------- Header --------------
 <cfloop from="1" to="3" index="j">
    <cfset count = count + 1>
    #count#. Name #count#
 </cfloop>
------------- Footer --------------
 <br class="pageBreak">
</cfloop>
</cfoutput>

I am trying to incorporate the Page #i#
into my page and am getting undesired results could you please help me understand where to place the code.
here is the code that I have unsuccessfully tried to implement your  solution
<cfset numberOfRecordsBeforeHeaderDisplay = 35>
<cfset pageBreakCounter = 0>
<cfoutput query="alphalist">


<!--- Display header --->

<cfif alphalist.currentRow mod numberOfRecordsBeforeHeaderDisplay EQ 1>
 <cfif pageBreakCounter eq 0>

      <!-- start newspaper table -->
  <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">


  <cfinclude template="alphaheadernumber.cfm">

<table width="100%">
    <tr>
 </cfif>
 <cfset pageBreakCounter = IncrementValue(pageBreakCounter)>
  <td>
        <table width="100%" height="90%">
          <tr>
            <td width="81%" valign="top" align="left">Name</td>
            <td width="2%">&nbsp;</td>
            <td align="left" width="17%" valign="top">Number </td>
          </tr>
          <td> </cfif>
          <!--- table cell display --->
          <tr> <font face="Arial, Helvetica, sans-serif" size="2">
            <td width="81%" valign="top" align="left">#EX_CO_Name#</td>
            <td width="2%">&nbsp;</td>
            <td width="17%" align="left" valign="top">#exhibitornumber#</td>
            </font> </tr>
          <!--- Display close table --->
          <td> <cfif alphalist.currentRow mod numberOfRecordsBeforeHeaderDisplay EQ 0 OR alphalist.currentRow EQ alphalist.recordCount>
        </table>
  </td>
    <cfif pageBreakCounter mod 2 eq 0 OR alphalist.currentRow EQ alphalist.recordCount>
      <cfset pageBreakCounter = 0>
      <!--- close newspaper table --->
      </table>
      <br class="pageBreak">
    </cfif>
     
</cfif>
</body>
</cfoutput>
thanks for the help
0
 
LVL 11

Expert Comment

by:jimmy282
Comment Utility
did u see the tag I told u to see?
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

Expert Comment

by:bing2x
Comment Utility
sorry, I was so busy to check my EE :), what's your last problem with that?? or maybe it has already solved... I didnt see any error on your code.. try to give me the error msg.. sorry..
0
 

Author Comment

by:jriver12
Comment Utility
bing2x I am not trying to use pagination all I am attempting to do is to add a page number on all of my pages dynamicaly. as with previous solution.

I will try some more maybe I am missing something.
0
 

Author Comment

by:jriver12
Comment Utility
jimmy282,

it would not come up on the search.??
0
 

Author Comment

by:jriver12
Comment Utility
bing2x
with the code above how do I implement this bit of code which would give me a page count on my page
<cfoutput>
<cfset count = 0>
<cfloop from="1" to="2" index="i">
Page #i#



</cfloop>
</cfoutput>
0
 
LVL 5

Accepted Solution

by:
nathans earned 100 total points
Comment Utility
Only one problem... You must know the number of pages before it starts printing....

-------------- code --------------------
<Cfset TotalPages=20>
<cfset page =1>

<cfoutput query="alphalist">
  <!--- your code --->
  #page# of #TotalPages#
  <br class="pageBreak">
  <cfset Page=Page+1>
</cfoutput>
-------------- code --------------------

Nathan
http://www.cftipsplus.com
0
 

Author Comment

by:jriver12
Comment Utility
I will keep trying it If I figure out how to count the pages I will post.

thanks for the insight.

this question has been up too long.

thanks again for all that participated.
0
 

Author Comment

by:jriver12
Comment Utility
Nathans

this code is not a problem (after giving it some thought)
<Cfset TotalPages=20>
<cfset page =1>

<cfoutput query="alphalist">
 <!--- your code --->
 #page# of #TotalPages#
 <br class="pageBreak">
 <cfset Page=Page+1>
</cfoutput>
I'll explain.
I have a code that cj helped develope it goes like this:

<cfset numberOfRecordsBeforeHeaderDisplay = 42>
<cfset pageBreakCounter = 0>


<cfoutput query="yourQuery">
<!--- Display header --->
<cfif yourQuery.currentRow mod numberOfRecordsBeforeHeaderDisplay EQ 1>
 <cfif pageBreakCounter eq 0>
    <!-- start newspaper table -->
    <table>
    <tr>
 </cfif>
 <cfset pageBreakCounter = IncrementValue(pageBreakCounter)>
  <td>
  <table>
    <tr><td>... header html </td></tr>
</cfif>
<!--- table cell display --->
display your data here.


<!--- Display close table --->
<cfif yourQuery.currentRow mod numberOfRecordsBeforeHeaderDisplay EQ 0 OR yourQuery.currentRow EQ yourQuery.recordCount>
  </table>
  </td>
    <cfif pageBreakCounter mod 2 eq 0 OR yourQuery.currentRow EQ yourQuery.recordCount>
      <cfset pageBreakCounter = 0>
      <!--- close newspaper table --->
      </tr></table>
      <!--- Insert your page break code here --->
    </cfif>
</cfif>
</cfoutput>
Now I alter that with parts of your  suggestion and got this:

<style media="print">
BR.pageBreak { page-break-after: always }
</style>

<cfset numberOfRecordsBeforeHeaderDisplay = 42>
<cfset pageBreakCounter = 0>

<cfset numberofrecords = "#yourquery.recordcount#">
<Cfset TotalPages =  numberofrecords/numberOfRecordsBeforeHeaderDisplay >

<cfset page =1>


<cfoutput query="yourQuery">
<!--- Display header --->
<cfif yourQuery.currentRow mod numberOfRecordsBeforeHeaderDisplay EQ 1>
 <cfif pageBreakCounter eq 0>
    <!-- start newspaper table -->
    <table>
    <tr>
 </cfif>
 <cfset pageBreakCounter = IncrementValue(pageBreakCounter)>
  <td>
  <table>
    <tr><td>... header html </td></tr>
</cfif>
<!--- table cell display --->
display your data here.


<!--- Display close table --->
<cfif yourQuery.currentRow mod numberOfRecordsBeforeHeaderDisplay EQ 0 OR yourQuery.currentRow EQ yourQuery.recordCount>
  </table>
  </td>
    <cfif pageBreakCounter mod 2 eq 0 OR yourQuery.currentRow EQ yourQuery.recordCount>
      <cfset pageBreakCounter = 0>
      <!--- close newspaper table --->
      </tr></table>
      <!--- Insert your page break code here --->
    </cfif>
</cfif>
</cfoutput>
 <br class="pageBreak">
<cfset page=page+1>

Now you can place #page# anywhere you want it and the page will break and you will now have a running count of pages ie.

page1
akjdsfalks

page 2
alksdj
0

Featured Post

Scale it in WD Gold

With up to ten times the workload capacity of desktop drives, WD Gold hard drives employ advanced technology to deliver among the best in reliability, capacity, power efficiency and performance.

Join & Write a Comment

Suggested Solutions

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now