Welkom op Scriptkiddies!
Disclaimer - FAQ - Contact - About - Adverteren
  Home   Artikelen   Forum   Topic openen   Chat   Gastenboek   Links   Aanmelden

  CSS   JavaScript   ASP   PHP   Perl


  Virtuax  MSN Stuff  WebSonic  Avondzon.nl  habbo-dj-music  scripttrip  Tuts.nl | Tutorial CMeer linkpartners

Pagina navigatie
Auteur: MijnNaam (lid)
Gepost: 22:06:55 13-07-2004
Stuur prive bericht
Nou eh, het maakt een array voor je met allemaal informatie voor je pagina navigatie. Een keer aanroepen en dan kun je 'm gebruiken, zonder onzin vooraf.

Voor meer uitleg: Zie script.

LET OP: JE MOET NOG WEL EVEN ZELF 3 CONSTANTEN DEFINIËREN! HELEMAAL BOVENAAN HET SCRIPT STAAN ZE!

(heb ik maar effe in het Nederlands gedaan, omdat ik nogal haast heb)
<?php
// constanten, hoef je niet persé hier neer te zetten
define('NAV_PAGENUMBERS'); // pagina nummers alleen
define('NAV_PREVIOUSNEXT'); // alleen vorige - volgende
define('NAV_BOTH'1); // pagina nummers en vorige - volgende

/*
***************************************************************************
* Function sql_navigation(), used to create a link-index of page numbers  *
* for paging through the records which come from your MySQL-database.     *
* Copyright (C) 2004 The Celestial Celebi.                                *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the   *
* Free Software Foundation; either version 2 of the License, or (at your  *
* option) any later version.                                              *
* This program is distributed in the hope that it will be useful, but     *
* WITHOUT ANY WARRANTY; without even the implied warranty of              *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU       *
* General Public License for more details.                                *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.               *
***************************************************************************
*/

/*
***************************************************************************
* @function: sql_navigation(): Returns an array for creating a            *
* pagination.                                                             *
* @param $rDatabaseconnection (resource): Your database connection, we    *
*  need it to get the total number of records from the database.  This    *
*  parameter must be given by reference.                                  *
* @param $aTable (string / array): The table where we need to take out    *
*  the records for the navigation, can be an array of two elements: 1st   *
*  is the table and the 2nd is a piece of query after the FROM.           *
* @param $sUrl (string): The name of the file in your URL, plus (if there *
*  is any) the query string, needed for making correct navigation links.  *
* @param $sAlias (string): The alias you want to give the navigation you  *
*  are making now, it becomes part of the URL: index.php?MYALIAS=40.      *
* @param $iPerpage (int): The number of records you want to display per   *
*  page.                                                                  *
* @param $iType (int): The type of navigation, you can use either the     *
*  constants or integer numbers, see constants for more information.      *
* @return array: All information you need to display your navigation.     *
*-------------------------------------------------------------------------*
* @started on: 12 May 2004 at 20:25:56 by The Celestial Celebi.           *
* @last edited on: 20 June 2004 at 11:36:38 by The Celestial Celebi.      *
* @constructs used: array, else, elseif, if, for, return.                 *
* @functions used: ceil, intval, is_array, isset, mysql_error,            *
* mysql_query, mysql_result, trigger_error, str_replace, strstr, trim.    *
***************************************************************************
*/

function sql_navigation(&$rDatabaseconnection$aTable$sUrl$sAlias$iPerpage$iType)
{
    if(
is_array($aTable))
    {
        
$sQuerybit ' ' $aTable[1];
        
$sTable $aTable[0];
    }
    else
    {
        
$sTable $aTable;
        
$sQuerybit '';
    }
    
$sSqlgetnumberofrecordsstring "SELECT COUNT(1) AS totalrecords FROM " $sTable $sQuerybit;
    if(!
$rSqlgetnumberofrecordsquery mysql_query($sSqlgetnumberofrecordsstring$rDatabaseconnection))
    {
        
trigger_error('sql_navigation(): Could not query the total number of records from database, ' mysql_error(), E_USER_WARNING);
        return;
    }
    else
    {
        
$iTotalrecords mysql_result($rSqlgetnumberofrecordsquery0'totalrecords');
        
$iTotalpages = ($iTotalrecords $iPerpage);
        
$iTotalpages ceil($iTotalpages);
        if(!isset(
$_GET[$sAlias]) || $_GET[$sAlias] > $iTotalpages || $_GET[$sAlias] < || intval($_GET[$sAlias]) != $_GET[$sAlias]) // a whole block.. it's here to validate the pagenumber as some users might f*ck it up
        
{
            
$iCurrent 1;
        }
        else
        {
            
$iCurrent intval($_GET[$sAlias]);
        }
        
$iStartpoint = (($iCurrent 1) * $iPerpage);
        if(
$iCurrent == $iTotalpages && ($iTotalrecords $iPerpage) != 0)
        {
            
$iEndpoint = ($iTotalrecords $iPerpage);
            if(
$iEndpoint == 0)
            {
                
$iEndpoint += 1;
            }
        }
        elseif(
$iTotalrecords == 0)
        {
            
$iEndpoint 0;
        }
        else
        {
            
$iEndpoint $iPerpage;
        }
        
$sNavigation '';
        if(
$iTotalpages != && $iTotalrecords != 0)
        {
            if(
strstr($sUrl'?'))
            {
                
$sUrlseperator '&';
            }
            else
            {
                
$sUrlseperator '?';
            }
            if(
$iType == NAV_BOTH || $iType == NAV_PAGENUMBERS)
            {
                for(
$i 1$i <= $iTotalpages$i++)
                {
                    if(
$iCurrent == $i)
                    {
                        
$sNavigation .= ' <b>' $i '</b> ';
                    }
                    else
                    {
                        
$sNavigation .= ' <a class="navigation" href="' $sUrl $sUrlseperator $sAlias '=' $i '">' $i '</a> ';
                    }
                }
            }
            if(
$iType == NAV_BOTH || $iType == NAV_PREVIOUSNEXT)
            {
                if(
$iCurrent != 1)
                {
                    
$sNavigation '<a class="navigation" href="' $sUrl $sUrlseperator $sAlias '=' . ($iCurrent 1) . '">vorige</a> ' $sNavigation;
                }
                else
                {
                    
$sNavigation 'vorige ' $sNavigation;
                }
                if(
$iCurrent $iTotalpages)
                {
                    
$sNavigation .= ' <a class="navigation" href="' $sUrl $sUrlseperator $sAlias '=' . ($iCurrent 1) . '">volgende</a>';
                }
                else
                {
                    
$sNavigation .= ' volgende';
                }
            }
            
$sNavigation str_replace('  '' '$sNavigation);
            
$sNavigation trim($sNavigation);
        }
        return array(
            
'current' => $iCurrent,
            
'navigation' => $sNavigation,
            
'startpoint' => $iStartpoint,
            
'endpoint' => $iEndpoint,
            
'totalrecords' => $iTotalrecords,
            
'totalpages' => $iTotalpages
        
);
    }
}
?>
download het script    




Reacties van leden

Auteur: toppe @ 02-09-2004

Je coptyright en uit leg boven in is groter dan het script zelf:p




Gebruikersnaam:
Wachtwoord:

Brochures.nl  gratis criminals...  forum probleem  sql file nodig!  wild west game  script gezocht  wat te denken ove...  rabo internetbank...  oehoe!  site tekoop  koppeling zoek &...

Scriptkiddies telt momenteel 6407 leden, er zijn 359 scripts en er zijn momenteel 8 mensen online waarvan 0 leden.

Hoeveel sites heb jij?
Geen
1
2
5
meer dan 5

Parkeren Schiphol Profielen tip NatuurRampen tip JS-Systems LoveBoyz Ringtones! Woning aanbod Weblog maken
Copyright by Jacob Slomp