Solved

page count

Posted on 2002-04-29
14
173 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Web Site Hosting 10 86
SSL sertificate 5 65
Question to locate the problem 18 106
DNS @ Naked Domain Record 5 83
This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

808 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