Answer 1 out of 1
 
A:

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

 
Comment About This Answer (or add your own answer)

Feed - Subscribe to changes to this Q&A Blog
ADVERTISEMENT
ADVERTISEMENT
AOL Autos Q&A is powered by Yedda an AOL Company
Copyright © 2006-2010, Yedda Inc. and respective copyright owners