• Answers
  • Web
Originated from
QueryCAT

How to generate page breaks for each record in ...

how to generate page breaks for each record in word doc using php


Share Send to a friend Watch Report
 
 

Posted Answers

 

Connect to your database. You can use the following script:
$dbh=mysql_connect ("localhost", "USERNAME", "PASSWORD") or die ('I cannot connect to the database because: ' . mysql_error());
Replace USERNAME with your username, PASSWORD with your password, and DATABASE with the data that you are extracting.

First establish how many rows of data from your database that you want to present to the user, per page. Establish the variable, $rowsPerPage and set it to the number of records you wish to display.
// how many rows to show per page
$rowsPerPage = 1;

Establish that the first page displayed is page 1. Establish the variable and assign it to the number 1.
// by default we show first page
$pageNum = 1;

Then, create an if statement to 'GET' the page number, assuming that it is defined. We are using the function isset() to check if 'page' has been established. Assign the result to the $pageNum variable from Step 3:
// if $_GET['page'] defined, use it as page number
if(isset($_GET['page']))
{
$pageNum = $_GET['page'];
}

 

The final part of Section 1 is creating the offset. When limiting a query to a database, two numbers can be used, which looks like this: LIMIT 0,10. The $offset variable is what record number the query starts from, in this case '0', and the rows per page, in this case '10', is how many records are to be listed until the query ends.
// counting the offset
$offset = ($pageNum - 1) * $rowsPerPage;

 

For more information visit:http://windows7.iyogi.net

Posted 2009-10-19T06:52:30Z

Sign in to participate

Got an answer for lalitha? Would you like to comment on the posted answers, or vote for the one which you think is the best?

Sign up for a free account, or sign in (if you're already a member).

Explore Related Questions

Other people asked questions on similar topics, check out the answers they received:


Q:

When would you use a manual page break

When would you use a manual page break
Submitted by cheryl cowan   1 year ago.
  • viewed 201 times
Last answer posted 2 months ago by dd


Feed - Subscribe to changes to this Q&A Blog
ADVERTISEMENT
  • Answers
  • Web
Copyright © 2006-2009, Yedda Inc. and respective copyright owners · CC License