Mysmilies.net die Smilies Datenbank

Script oder Datei finden :

 
-Startseite
-Newsarchiv
-Newsletter
-Mein Dreamcodes
-Scripte
-eBooks
-Online Speicher
-Datenbanken
-Webseiten
-Trickfilm
-Web Grafiken
-Bildbearbeiter
-Browser
-EMail Software
-Ftp Clienten
-Betriebssysteme
-Texteditoren
-Wampserver
-Office Pakete
-Antivirus
-System Cleaner
-Recovery Tools
-Php Schnipsel
-Ajax Schnipsel
-VB Schnipsel
-Tutorials
-Workshops
-Webkatalog
-Leserforum
-Erweiterte Suche
-Sitemap
-Impressum
-neuste Downloads

1. Selfphp (1851)
2. Xampp OS X (1737)
3. Xampp Linux (1725)
4. Xampp Windows (1750)

-neuste Tutorials

1. Samsung S20 rooten (2172)
2. Gratis USA Nummer (15920)
3. RAID (14735)
4. Text auf Grafik (15588)


Tutorials Pager Klasse

 

Pager Klasse

Klasse im eine Datenbank-Abfrage über mehrere Seiten ausgeben zu lassen

Script:

<?php
class Paging {

var $int_num_result; // Number of result to show per page (decided by user)
var $int_nbr_row; // Total number of items (SQL count from db)
var $int_cur_position;// Current position in recordset
var $str_ext_argv; // Extra argv of query string

// ------------------------------------------------------------------------ Constructor
//
function Paging( $int_nbr_row, $int_cur_position, $int_num_result, $str_ext_argv = "\" ){
$this->int_nbr_row = $int_nbr_row;
$this->int_num_result = $int_num_result;
$this->int_cur_position = $int_cur_position;
$this->str_ext_argv = urldecode( $str_ext_argv );
} // End constructor

// ------------------------------------------------------------------- getNumberOfPage()
// This function returns the total number of page to display.
function getNumberOfPage(){
$int_nbr_page = $this->int_nbr_row / $this->int_num_result;
return $int_nbr_page;
} // end function

// -------------------------------------------------------------------- getCurrentPage()
// This function returns the current page number.
function getCurrentPage(){
$int_cur_page = ( $this->int_cur_position * $this->getNumberOfPage() ) / $this->int_nbr_row;
return number_format( $int_cur_page, 0 );
} // end function

// ----------------------------------------------------------------------- getPagingArray()
// This function print the paging to the screen.
// This function returns an array:
// $array_paging[\'lower\'] lower limit of where we are in result set
// $array_paging[\'upper\'] upper limit of where we are in result set
// $array_paging[\'total\'] total number of result
// $array_paging[\'previous_link\'] href tag for previous link
// $array_paging[\'next_link\'] href tag for next link
function getPagingArray(){
global $PHP_SELF;

$array_paging[\'lower\'] = ( $this->int_cur_position + 1 );

if( $this->int_cur_position + $this->int_num_result >= $this->int_nbr_row ){
$array_paging[\'upper\'] = $this->int_nbr_row;
}else{
$array_paging[\'upper\'] = ( $this->int_cur_position + $this->int_num_result );
}

$array_paging[\'total\'] = $this->int_nbr_row;

if ( $this->int_cur_position != 0 ){
$array_paging[\'previous_link\'] = \"<a href=\\\"$PHP_SELF?int_cur_position=\". ( $this->int_cur_position - $this->int_num_result ).$this->str_ext_argv .\"\\\">\";


if( ( $this->int_nbr_row - $this->int_cur_position ) > $this->int_num_result ){
$int_new_position = $this->int_cur_position + $this->int_num_result; 
$array_paging[\'next_link\'] = \"<a href=\\\"$PHP_SELF?int_cur_position=$int_new_position\". $this->str_ext_argv .\"\\\">\";
}
return $array_paging;
} // end function

// ----------------------------------------------------------------------- getPagingRowArray()
// This function returns an array of string (href link with the page number)
function getPagingRowArray(){
global $PHP_SELF;

for( $i=0; $i<$this->getNumberOfPage(); $i++ ){
// if current page, do not make a link
if( $i == $this->getCurrentPage() ){
$array_all_page[$i] = \"<b>\". ($i+1) .\"</b>\";
}else{
$int_new_position = ( $i * $this->int_num_result );
$array_all_page[$i] = \"<a href=\\\"\". $PHP_SELF .\"?int_cur_position=$int_new_position$this->str_ext_argv\\\">\". ($i+1) .\"</a>\";
}
}
return $array_all_page;
} // end function
}; // End Class

// ==============================================================
// Exemple Usage
// Note: I make 2 query to the database for this exemple, it
// could (and should) be made with only one query...
// ==============================================================

include( \"db_mysql.php\" );

// New instance of database object, from phplib (http://phplib.sourceforge.net/)
$db = new db_data();

// If current position is not set, set it to zero
if( !isset( $int_cur_position ) || $int_cur_position == 0 ){
$int_cur_position = 0;
}

// Number of result to display on the page, will be in the LIMIT of the sql query also
$int_num_result = 20;
$extargv = \"&argv1=1&argv2=2\"; // extra argv here (could be anything depending on your page)

// Get the total number of result from db
$sql1 = \"Select count( key ) as nbr FROM table\";

if ( !$db->query( $sql1 )){ print \"\\n<p>ERREUR $sql1\"; exit; }
$db->next_record();
$result_from_sql1 = $db->f(\"nbr\");

// New instance of the Paging class, you can modify the color and the width of the html table
$p = new Paging( $result_from_sql1, $int_cur_position, $int_num_result, $extargv );

// Load up the 2 array in order to display result
$array_paging = $p->getPagingArray();
$array_row_paging = $p->getPagingRowArray();

// Display the result as you like...
print \"Results \". $array_paging[\'lower\'];
print \" to \". $array_paging[\'upper\'];
print \" of \". $array_paging[\'total\'];
print \"&nbsp;&nbsp;\". $array_paging[\'previous_link\'] .\"<<<</a> \" ;
for( $i=0; $i<sizeof($array_row_paging); $i++ ){
print $array_row_paging[$i] .\"&nbsp;\";
}
print $array_paging[\'next_link\'] .\">>></a>\";

// The above exemple print somethings like:
// Results 1 to 20 of 597 <<< 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 >>>
// Of course you can now play with array_row_paging in order to print
// only the results you would like...

// Now go on with the rest of you page...
// Select only fields needed according to paging
$sql2 = \"Select * FROM my_table ORDER BY id \"
.\"LIMIT $int_cur_position, $int_num_result\";
?>

 
Seiten : 1
hinzugefügt am : 28.01.2005
Autor : Lemaire
Listings ID : 646
Status zum lesen : Gast
gelesen : 6665 mal
[Druckansicht] [Lesercharts] [RSS] [zur Übersicht]
 
 

Die Möglichkeit diesen Artikel zu verlinken :

HTML-Code:

Code zum Einbinden in ein Forum:


Hinweis : Das lesen des Artikels Pager Klasse - listings ID: 646 auf Dreamcodes, sowie Link Verweise auf Internetseiten fremder Anbieter erfolgen auf eigene Gefahr. Dreamcodes haftet nicht für Schäden, die aus der Verwendung des Inhaltes der Artikel erfolgen könnten. Schadenersatzansprüche, aus welchem Rechtsgrund auch immer, sind ausgeschlossen !
-Live Statistik
Datum: 21.11.2024
Uhrzeit: 21:21 Uhr
Online: 22 User
User heute: 25058
User allgem.: 35307886

Eingeloggt als Gast
-Download des Monats
-
-unsere Monats Umfrage
Welche Serie ist besser?

The Blacklist
House of the Dragon
Die Ringe der Macht
The Sandman
Manifest

-unsere Bestseller