WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Paginating the mySQL data
Categories : PHP, Algorithms, Databases, MySQL, HTML and PHP Click here to Update Your Picture
Saravanan .R
Date : Aug 10th 2004
Grade : 3 of 5 (graded 4 times)
Viewed : 16059
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Saravanan .R
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 



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

------------------------------------------------------------
&lt;?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 &gt;= $rowsPerPage)
            {
                $pageString .= `&lt;a href="`.$PHP_SELF.`?pageNo=1&startPos=1&perPageDisplay=`.$rowsPerPage.`" title="Previous Page"&gt;&lt;font color="black"&gt;&lt;b&gt;First &lt;/b&gt;&lt;/a&gt;&lt;/font&gt; `;
            }

            If($startPos &gt;= $tenPages )
            {
                $back10Position = $startPos - $tenPages ;
                $back10Page = round( $back10Position / $rowsPerPage );
                $pageString .= `&lt;a href="`.$PHP_SELF.`?pageNo=`.$back10Page.`&startPos=`.$back10Position .`&perPageDisplay=`.$rowsPerPage.`" title="Previous 10 Pages"&gt;&lt;font color="red"&gt;&lt;b&gt;&lt;&lt; &lt;/b&gt;&lt;/font&gt;&lt;/a&gt;  `;
            }

            If($startPos &gt;= $rowsPerPage) 
            {
                $backPosition = $startPos - $rowsPerPage;
                $backPage = ceil( $backPosition / $rowsPerPage ); 

                $pageString .= `&lt;a href="`.$PHP_SELF.`?pageNo=`.$backPage.`&startPos=`.$backPosition.`&perPageDisplay=`.$rowsPerPage.`" title="Previous Page"&gt;&lt;font color="blue"&gt;Previous &lt;/a&gt;&lt;/font&gt; `;
            }
                
            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 &lt; $pageCount; $i = $i + $rowsPerPage,$pgCnt++)        // ,$PageNo++
                {    
                    if ( $thisPage == $pgCnt )
                    {
                        $pageString .= ` &lt;a href="`.$PHP_SELF.`?pageNo=`.$pgCnt.`&startPos=`.$i.`&perPageDisplay=`.$rowsPerPage.`" title="Page `.$pgCnt.`""&gt;&lt;font color="red"&gt;&lt;b&gt;`.$pgCnt.`&lt;/b&gt;&lt;/font&gt;&lt;/a&gt; `;
                    }
                    else    // if ($i &lt; $totalRows) 
                    {
                        $pageString .= ` &lt;a href="`.$PHP_SELF.`?pageNo=`.$pgCnt.`&startPos=`.$i.`&perPageDisplay=`.$rowsPerPage.`" title="Page `. $pgCnt.`""&gt;`.$pgCnt.`&lt;/a&gt; `;
                    };
                    $page++;
                };
            }

            $nextPosition = $startPos + $rowsPerPage;
            $nxtPage = ceil( $nextPosition / $rowsPerPage ); 

            If($totalRows == ``) 
            {

                $pageString .= `&lt;a href="`.$PHP_SELF.`?pageNo=`.$nxtPage.`&startPos=`.$nextPosition.`&perPageDisplay=`.$rowsPerPage.`" title="Next Page"&gt;&lt;font color="blue" &gt;Next &lt;/font&gt;&lt;/a&gt; `;
            }
            elseif($startPos &lt; $totalRows ) 
            {
                If ( $nextPosition &lt; $totalRows )
                {
                    $pageString .= `&lt;a href="`.$PHP_SELF.`?pageNo=`.$nxtPage.`&startPos=`.$nextPosition.`&perPageDisplay=`.$rowsPerPage.`" title="Next Page"&gt;&lt;font color="blue" title="Next Page"&gt;Next &lt;/font&gt;&lt;/a&gt;  `;
                }
            }

            If($startPos &lt; $totalRows ) 
            {
                $next10Position = $startPos + $tenPages ;

                If($next10Position &lt; $totalRows )
                {
                    $next10Position = $startPos + $tenPages ;
                    $nxt10Page = round( $next10Position / $rowsPerPage );
                    $pageString .= `&lt;a href="`.$PHP_SELF.`?&pageNo=`.$nxt10Page.`&startPos=`.$next10Position .`&perPageDisplay=`.$rowsPerPage.`" title="Next 10 Pages"&gt;&lt;font color="red"&gt;&lt;b&gt;
&gt;&gt;&lt;/b&gt;&lt;/font&gt;&lt;/a&gt;`;
                }

                $lastPage = ceil( $totalRows / $rowsPerPage );

                If ($thisPage != $lastPage)
                {
                    $lastPosition = $rowsPerPage * ( $lastPage - 1) + 1 ;
                    $pageString .= `&lt;a href="`.$PHP_SELF.`?pageNo=`.$lastPage.`&startPos=`.$lastPosition.`&perPageDisplay=`.$rowsPerPage.`" title="Last Page"&gt;&lt;font color="black" title="Last Page"&gt;&lt;b&gt; Last&lt;/b&gt;&lt;/font&gt;&lt;/a&gt;  `;
                }

            }

            return $pageString;
        }
?&gt;
------------------------------------------------------------