1. Go to this page and download the library: Download mynuolr/datatables 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/ */
mynuolr / datatables example snippets
mir\Datatables\Datatables;
use Ozdemir\Datatables\DB\MySQL;
$config = [ 'host' => 'localhost',
'port' => '3306',
'username' => 'homestead',
'password' => 'secret',
'database' => 'sakila' ];
$dt = new Datatables( new MySQL($config) );
$dt->query("Select film_id, title, description from film");
echo $dt->generate();
$dt = new Datatables( new MySQL($config) );
$dt->query("Select id, name, email, address, plevel from users");
$dt->edit('id', function($data){
// return an edit link.
return "<a href='user.php?id=" . $data['id'] . "'>edit</a>";
});
$dt->edit('email', function($data){
// return [email protected] to m***@mail.com
return preg_replace('/(?<=.).(?=.*@)/u','*', $data['email']);
});
$dt->edit('address', function($data){
// check if user has authorized to see that
$current_user_plevel = 4;
if ($current_user_plevel > 2 && $current_user_plevel > $data['plevel']) {
return $data['address'];
}
return 'you are not authorized to view this column';
});
echo $dt->generate();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.