PHP Classes
elePHPant
Icontem

File: exSimples.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Mario cesar chapela barboza  >  Good Pagination  >  exSimples.php  >  Download  
File: exSimples.php
Role: Example script
Content type: text/plain
Description: Simple example
Class: Good Pagination
Show links to browse listings split in pages
Author: By
Last change:
Date: 6 years ago
Size: 1,605 bytes
 

Contents

Class file image Download
<?php
   
/*
    *Exemplo de uso simples:
    */
   
require("paginacao.class.php");
   
$link = mysql_connect("localhost", "root", "");
    if(
$link){
        if (!
mysql_select_db("bancoTeste", $link)) {
            exit(
"It was not possible to select database: bancoTeste".
               
"<br>On Server:localhost".
               
"<br>With the user: root".
               
"<br>And the Password: '' ");
        }
    }else{
        exit(
"Unable to login to Server: localhost".
           
"<br>With the user: root".
           
"<br>And the Password: '' ".
           
"<br>And so it is not possible to select the Database:bancoTeste");
    }
   
$query2 = mysql_query("SELECT * FROM `tabela`");
   
$howMany = mysql_num_rows($query2);
   
   
$limit_on_earnings_per_page = 5;
   
   
$page = (isset($_GET["pg"])) ? $_GET["pg"] : 1;
   
$start = ($page != 0)? ($page - 1) * $limit_on_earnings_per_page : 0;
   
$query = mysql_query("SELECT * FROM `tabela` LIMIT $start, $limit_on_earnings_per_page;");
    while(
$dados = mysql_fetch_array($query)){
        Echo
"Value of Field = ".$dados["campo"]."<br /> \n";
    }
   
   
$instantiates = new paginacao();
   
$instantiates->configuracoesLogica["pg_Atual"] = $page;
   
$instantiates->configuracoesLogica["qntTroco"] = $howMany;
   
   
$instantiates->configuracoesTemplates["LINK"] = "<a style='text-decoration:none;' href='http://localhost/paginacao/exSimples.php?pg=###PAGINA###'><strong>###MENSAGEM###</strong></a> \n";
   
$instantiates->configuracoesTemplates["BLOCO"] = "<strong>[###INICIO###-###FIM###]</strong> \n";
   
$instantiates->configuracoesTemplates["PG_ATUAL"] = "<strong>###PAGINA###</strong> \n";
    echo
$instantiates->geraPaginacao();
?>