PHP Classes

File: examples/itemReplace.php

Recommend this page to a friend!
  Classes of Basilio  >  teaPagination  >  examples/itemReplace.php  >  Download  
File: examples/itemReplace.php
Role: Example script
Content type: text/plain
Description: Example script
Class: teaPagination
Display pagination for database queries using PDO
Author: By
Last change: Update itemReplace.php
Date: 5 years ago
Size: 3,943 bytes



Class file image Download
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <link href="assets/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
        <link href="//" rel="stylesheet" type="text/css" />
        <link href="assets/css/highlight/default.css" rel="stylesheet" type="text/css" />
        <script src="assets/js/jquery-1.7.2.min.js" type="text/javascript"></script>
        <script src="assets/js/bootstrap.min.js" type="text/javascript"></script>
        <script src="assets/js/highlight.pack.js" type="text/javascript"></script>
                margin: 0 auto;
                max-width: 800px;
                padding-top: 50px;
        <nav class="navbar navbar-default" role="navigation">
            <div class="container">
                <div class="navbar-header">
                    <a class="navbar-brand" href="#">teaPagination</a>
                <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-3">
                    <a href="../index.html" class="btn btn-default navbar-btn"><i class="fa fa-home"></i> Home</a>
        <div class="wrapper">
            <div class="alert alert-info"><strong>Please, </strong>Click <a href="javascript:void(0)" onClick="$('.code').toggle()" style="font-weight:bold">here</a> to view the code</div>
            <div class="row">
                <pre class="code php html">
//create the sql statement to be processed
$sql = 'SELECT * FROM countries';
//added the class options
$options = array(
    'beginLoop' => '&lt;blockquote&gt;',
    'endLoop' => '&lt;/blockquote&gt;',
    'maxButtons' => 5,
    'nameVar' => 'pg',
    'itemsPage' => 10,
    'buttons' => array('class' => 'pagination'),
    'connect_db' => array('user' => 'root', 'database' => 'example', 'password' => 'passw')
//Instance is started
$pagination = new teaPagination($sql, $options);
//It substitutes the words keys by value
$pagination->loop('&lt;p&gt;&lt;a href="javascript:void(0)" onClick="alert(\'Country: {short_name}\')"&gt;{short_name}&lt;/a&gt;&lt;/p&gt;&lt;small&gt;{long_name}&lt;/small&gt;');
//The result is shown
echo '&lt;div class="row" style="margin-bottom:20px;margin-left:5px"&gt;Showing ' . $pagination->currentPage . ' - ' . $pagination->TotalPage . ' of ' . $pagination->TotalRecord . ' entries&lt;/div&gt;&lt;hr/&gt;' . $pagination->render() . $pagination->buttons();
$sql = 'SELECT * FROM countries';
$options = array(
'beginLoop' => '<blockquote>',
'endLoop' => '</blockquote>',
'maxButtons' => 5,
'nameVar' => 'pg',
'itemsPage' => 10,
'buttons' => array('class' => 'pagination'),
'connect_db' => array('user' => USER, 'database' => DATABASE, 'password' => PASSWORD)
$pagination = new teaPagination($sql, $options);
$pagination->loop('<p><a href="javascript:void(0)" onClick="alert(\'Country: {short_name}\')">{short_name}</a></p><small>{long_name}</small>');
'<div class="row" style="margin-bottom:20px;margin-left:5px">Showing '.$pagination->currentPage.' - '.$pagination->TotalPage.' of '.$pagination->TotalRecord.' entries</div><hr/>'.$pagination->render().$pagination->buttons();