Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

page count

Posted on 2002-04-29
14
175 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
ID: 6978114
go here
http://devex.macromedia.com/developer/gallery

and search for cf_nextpage

Its exactly what u want.

Jimmy
0
 

Expert Comment

by:bing2x
ID: 6980047
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
ID: 6980199
bing2x

What is the need for the form?
0
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 

Expert Comment

by:bing2x
ID: 6982717
used for the "NEXT PAGE" or "PREVIOUS PAGE"
0
 

Author Comment

by:jriver12
ID: 6984734
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
ID: 6986513
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
ID: 6989543
did u see the tag I told u to see?
0
 

Expert Comment

by:bing2x
ID: 6990936
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
ID: 6991082
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
ID: 6991089
jimmy282,

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

Author Comment

by:jriver12
ID: 6991140
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
ID: 7001903
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
ID: 7002183
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
ID: 7060005
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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…
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

860 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