Function Name : pageSplit()
Author Name: Saravanan.R
Version: 1.0
Email: saravanan.r@gmail.com
Description : To display the mySQL data into Pagewise display. According to the pageLength settings. User can easily modify the pagelength according to his requirement.
Usage: $pageLink = pageSplit($startPos, $rowsPerPage = '', $totalRows = '' )
It's having three Parameters:
Parameters Description:
-----------------------
a. $startPos - Starting Position of the Page
b. $rowsPerPage - Length of the rows to be displayed in a Page.
c. $totalRows - Total No of Records or Array count which to be displayed by Pagewise.
If anybody having problems with this function script, feel free to report with error message.
@ : saravanan.r@gmail.com
[code]
<?php
function pageSplit ( $startPos , $rowsPerPage = '' , $totalRows = '' )
{
$numPages = $totalRows / $rowsPerPage ;
$tenthPages = $rowsPerPage * 10 ;
If( $startPos >= $tenthPages )
{
$back10Position = $startPos - $tenthPages ;
$pageString .= '<a href="' . $PHP_SELF . '?startPos=' . $back10Position . '&perPageDisplay=' . $rowsPerPage . '" title="Previous 10 Pages"><font color="red"><< </font></a> ' ;
}
if( $startPos >= $rowsPerPage )
{
$backPosition = $startPos - $rowsPerPage ;
$pageString .= '<a href="' . $PHP_SELF . '?startPos=' . $backPosition . '&perPageDisplay=' . $rowsPerPage . '" title="Previous Page"><font color="blue">Back</a></font> ' ;
}
if( $totalRows != '' )
{
$page = ceil ( $startPos / $rowsPerPage );
$pageCount = $page + $numPages ;
$PageNo = ceil ( $startPos / $rowsPerPage ) ;
// echo ' Page No ' . $PageNo ;
for( $i = 1 , $pgCnt = 1 ; $page <= $pageCount ; $i = $i + $rowsPerPage )
{
if ( $PageNo == $pgCnt )
{
$pageString .= ' <a href="' . $PHP_SELF . '?startPos=' . $i . '&perPageDisplay=' . $rowsPerPage . '" title="Page ' . $pgCnt . '""><font color="red"><b>' . $pgCnt . '</b></font></a> ' ;
$pgCnt ++;
}
elseif ( $i < $totalRows )
{
$pageString .= ' <a href="' . $PHP_SELF . '?startPos=' . $i . '&perPageDisplay=' . $rowsPerPage . '" title="Page ' . $pgCnt . '"">' . $pgCnt . '</a> ' ;
$pgCnt ++;
};
$page ++;
};
}
$nextPosition = $startPos + $rowsPerPage ;
if( $totalRows == '' )
{
$pageString .= '<a href="' . $PHP_SELF . '?startPos=' . $nextPosition . '&perPageDisplay=' . $rowsPerPage . '" title="Next Page"><font color="blue" >Next </font></a> ' ;
}
elseif( $startPos < $totalRows )
{
If ( $nextPosition < $totalRows )
{
$pageString .= '<a href="' . $PHP_SELF . '?startPos=' . $nextPosition . '&perPageDisplay=' . $rowsPerPage . '" title="Next Page"><font color="blue" title="Next Page">Next </font></a> ' ;
}
}
if( $startPos < $totalRows )
{
$next10Position = $startPos + $tenthPages ;
If( $next10Position < $totalRows )
{
$next10Position = $startPos + $tenthPages ;
$pageString .= '<a href="' . $PHP_SELF . '?startPos=' . $next10Position . '&perPageDisplay=' . $rowsPerPage . '" title="Next 10 Pages"><font color="red"> >></font></a>' ;
}
}
return $pageString ;
}
?>
A very simple way to build and do a hierarchical html categories browser without javascript , just using html php and mySql
Categories : HTML and PHP , Databases , Algorithms , PHP , MySQL Browse a MySQL database & draw a tree view & load final items into a template page. Categories : MySQL , Complete Programs , Algorithms , PHP , Databases A PHP useradmin for MySQL. Uploading is easy. The only thing you need is
PHP and MySQL installed! Categories : MySQL , Databases , PHP , HTML and PHP dynamic table columns Categories : PHP , HTML and PHP , Arrays , Databases , MySQL Pull Down Surfing - Surf on Change Categories : Java Script , MySQL , HTML and PHP , PHP , Databases Complex paging with no resultset limit Categories : PHP , MySQL , Databases , Output Control , HTML and PHP phpFormGenerator for Dynamic Form Generation from MySQL Categories : PHP , PHP Classes , MySQL , Databases , HTML and PHP Functions for loading images into a MySQL database and displaying them. Categories : Graphics , HTML and PHP , MySQL , PHP , Databases Dynamically generated pop-ups (Select items) Categories : PHP , HTML and PHP , MySQL , Databases Message of the Day - Random Message (Needs MySQL!) Categories : Databases , HTML and PHP , PHP , MySQL Required form fields that pull from MySQL database Categories : PHP , HTML and PHP , Databases , MySQL mySQL/PHP/search with multientry
form and table output with colored rows Categories : PHP , Beginner Guides , MySQL , HTML and PHP , Databases Database resultset navigation Categories : PHP , HTML and PHP , Databases , MySQL , Navigation Creating thumbnails from MySQL Blobs online Categories : PHP , MySQL , Graphics , HTML and PHP , Databases Editing the virtusertable and sendmail.cw via PHP3.0 and Mysql Categories : MySQL , HTML and PHP , PHP , Databases
Saravanan .R wrote : 1180
Plz. find the Updated Version of pageSplit function
------------------------------------------------------------
<?php
/*
Function Name : pageSplit()
Author Name: Saravanan.R
Version: 1.1
Email: saravanan.r@gmail.com
Description : To display the mySQL data into Pagewise display. According to the pageLength settings. User can easily modify the pagelength according to his requirement.
Usage: $pageLink = pageSplit($startPos, $rowsPerPage = ``, $totalRows = `` )
It`s having three Parameters:
Parameters Description:
-----------------------
a. $startPos - Starting Position of the Page
b. $rowsPerPage - Length of the rows to be displayed in a Page.
c. $totalRows - Total No of Records or Array count which to be displayed by Pagewise.
CONCLUSION:
Well, I think that`s it ! Please, feel free to send any feedbacks, corrections, questions, suggestions @ : saravanan.r@gmail.com
*/
function pageSplit($startPos, $rowsPerPage = ``, $totalRows = `` )
{
$numPages = $totalRows / $rowsPerPage ;
$tenPages = $rowsPerPage * 10 ;
If( $startPos >= $rowsPerPage)
{
$pageString .= `<a href="`.$PHP_SELF.`?pageNo=1&startPos=1&perPageDisplay=`.$rowsPerPage.`" title="Previous Page"><font color="black"><b>First </b></a></font> `;
}
If($startPos >= $tenPages )
{
$back10Position = $startPos - $tenPages ;
$back10Page = round( $back10Position / $rowsPerPage );
$pageString .= `<a href="`.$PHP_SELF.`?pageNo=`.$back10Page.`&startPos=`.$back10Position .`&perPageDisplay=`.$rowsPerPage.`" title="Previous 10 Pages"><font color="red"><b><< </b></font></a> `;
}
If($startPos >= $rowsPerPage)
{
$backPosition = $startPos - $rowsPerPage;
$backPage = ceil( $backPosition / $rowsPerPage );
$pageString .= `<a href="`.$PHP_SELF.`?pageNo=`.$backPage.`&startPos=`.$backPosition.`&perPageDisplay=`.$rowsPerPage.`" title="Previous Page"><font color="blue">Previous </a></font> `;
}
If($totalRows != ``)
{
$page = ceil($startPos / $rowsPerPage);
$pageCount = $page + $numPages;
$thisPage = ceil($startPos / $rowsPerPage);
$PageNo = ceil($startPos / $rowsPerPage ) ;
$prv5Page = $thisPage - 5 ;
$nxt5Page = $thisPage + 5 ;
for($i = 1,$pgCnt=1; $page < $pageCount; $i = $i + $rowsPerPage,$pgCnt++) // ,$PageNo++
{
if ( $thisPage == $pgCnt )
{
$pageString .= ` <a href="`.$PHP_SELF.`?pageNo=`.$pgCnt.`&startPos=`.$i.`&perPageDisplay=`.$rowsPerPage.`" title="Page `.$pgCnt.`""><font color="red"><b>`.$pgCnt.`</b></font></a> `;
}
else // if ($i < $totalRows)
{
$pageString .= ` <a href="`.$PHP_SELF.`?pageNo=`.$pgCnt.`&startPos=`.$i.`&perPageDisplay=`.$rowsPerPage.`" title="Page `. $pgCnt.`"">`.$pgCnt.`</a> `;
};
$page++;
};
}
$nextPosition = $startPos + $rowsPerPage;
$nxtPage = ceil( $nextPosition / $rowsPerPage );
If($totalRows == ``)
{
$pageString .= `<a href="`.$PHP_SELF.`?pageNo=`.$nxtPage.`&startPos=`.$nextPosition.`&perPageDisplay=`.$rowsPerPage.`" title="Next Page"><font color="blue" >Next </font></a> `;
}
elseif($startPos < $totalRows )
{
If ( $nextPosition < $totalRows )
{
$pageString .= `<a href="`.$PHP_SELF.`?pageNo=`.$nxtPage.`&startPos=`.$nextPosition.`&perPageDisplay=`.$rowsPerPage.`" title="Next Page"><font color="blue" title="Next Page">Next </font></a> `;
}
}
If($startPos < $totalRows )
{
$next10Position = $startPos + $tenPages ;
If($next10Position < $totalRows )
{
$next10Position = $startPos + $tenPages ;
$nxt10Page = round( $next10Position / $rowsPerPage );
$pageString .= `<a href="`.$PHP_SELF.`?&pageNo=`.$nxt10Page.`&startPos=`.$next10Position .`&perPageDisplay=`.$rowsPerPage.`" title="Next 10 Pages"><font color="red"><b>
>></b></font></a>`;
}
$lastPage = ceil( $totalRows / $rowsPerPage );
If ($thisPage != $lastPage)
{
$lastPosition = $rowsPerPage * ( $lastPage - 1) + 1 ;
$pageString .= `<a href="`.$PHP_SELF.`?pageNo=`.$lastPage.`&startPos=`.$lastPosition.`&perPageDisplay=`.$rowsPerPage.`" title="Last Page"><font color="black" title="Last Page"><b> Last</b></font></a> `;
}
}
return $pageString;
}
?>
------------------------------------------------------------