PHP code example of criativamos / paginator

1. Go to this page and download the library: Download criativamos/paginator library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

criativamos / paginator example snippets


$query = "SELECT * FROM mock_data"
//the first parameter is a PDO instance with database connection
//the third parameter is the number of items per page. The default value is 15
$pg = new \Criativamos\Paginator\Paginator($pdoconnection, $query, 10);
//print result
if($pg->rowCount() > 0){
    foreach ($pg->getData() as $data){
        echo '<tr>';
        echo '<td>'.$data->id.'</td>';
        echo '<td>'.$data->first_name.'</td>';
        echo '<td>'.$data->last_name.'</td>';
        echo '<td>'.$data->email.'</td>';
        echo '</tr>';
    }
}
...
//pagination
$pg->render();

$query = "SELECT * FROM mock_data"
$pg = new \Criativamos\Paginator\Paginator($pdoconnection, $query);
print_r( $pg->results() );