Site Navigation Code

  Home arrow Site Navigation Code arrow Page Scroller
SITE NAVIGATION CODE

Page Scroller
By: Codewalkers
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2002-01-18

    Table of Contents:

     
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    advertisement
    If you retrieve a content from database, is simple if the record you have to display is short the problem will appear when the records is too big to fit in one page, then you have split it in to several pages.
    This snippet gives you a page-scroller with link << PREV and NEXT >>


    By :

    <?
    /********************************************************************
    * page scroller code snippet.
    *
    * Copyright (C) 2001 Wibisono Sastrodiwiryo.
    * This program is free software licensed under the
    * GNU General Public License (GPL).
    *
    * CyberGL => Application Service Provider
    * http://www.cybergl.co.id
    * office@cybergl.co.id
    *
    * $Id: scroller.php3,v 0.1 2001/05/20 20:12:21 wibi Exp $
    *********************************************************************/

    #---------------------------------------database configuration

    $db_user = "root";
    $db_pass = "pass";
    $db_name = "phpMember";
    $db_host = "localhost";

    mysql_pconnect($db_host, $db_user, $db_pass) or die("Unable to connect to SQL server");
    mysql_select_db($db_name) or die("Unable to select database");

    #---------------------------------------page scroller configuration

    $offset+=0;
    $item_perpage= 2; #----change this to define how many item per page
    $prev= $offset-$item_perpage;
    $next= $offset+$item_perpage;
    if ($prev <= 0) $prev=0;

    #---------------------------------------query configuration

    $tbl_search = "country";
    $field="name ";

    $query="SELECT $field FROM $tbl_search WHERE $field LIKE '%$keyword%' LIMIT $offset, $item_perpage";
    #----modify the where clause to fit your query need

    ?>

    <html>
    <head><title>CyberGL Page Scroller</title></head>
    <body>
    Query:
    <?echo $query;?>
    <hr>
    <?
    #---------------------------------------query process
    $data=mysql_query($query);
    $no=1;
    while ($result=mysql_fetch_array($data)) {
    ?>
    NO: <?echo $no+$offset;?>. <?echo $result[name]?><p>
    <? $no++;
    }
    #---------------------------------------page scroller
    ?>
    <table width="100%" cellpadding=0 cellspacing=0 border=0>
    <tr>
    <td><a href="scroller.php3?offset=<?echo $prev?>&keyword=<?echo $keyword?>">&lt;&lt; PREV</a></td>
    <td align=right><a href="scroller.php3?offset=<?echo $next?>&keyword=<?echo $keyword?>">NEXT &gt;&gt;</a></td>
    </tr>
    </table>


    </body>
    </html>
    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

    More Site Navigation Code Articles
    More By Codewalkers

    blog comments powered by Disqus

    SITE NAVIGATION CODE ARTICLES

    - Simple Menu System
    - Simply image viewer script
    - Simple File Lister
    - Dynamic Error Pages
    - BSoftEditor
    - Yahoo Status
    - Page numbers
    - PHP Search Navigator 1.0
    - Simple Page Navigation
    - An easy page browser ( prev 6 7 8 9 10 next )
    - AutoIndex PHP Script (Directory Indexer)
    - Bs_HtmlNavigation (Navigation and Sitemap cl...
    - Another Paging with Stage
    - Website Navigation via PHP
    - MySQL Paging Class


    © 2003-2012 by Developer Shed. All rights reserved. DS Cluster 2 - Follow our Sitemap