1. Go to this page and download the library: Download datatables.net/php 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/ */
datatables.net / php example snippets
$db = new Database( [
'type' => '', // Database type: "Mysql", "Postgres", "Sqlserver", "Sqlite"
'user' => '', // Database user name
'pass' => '', // Database password
'host' => '', // Database host
'port' => '', // Database connection port (can be left empty for default)
'db' => '' // Database name
]);
// DataTables PHP library
include( "../lib/DataTables.php" );
// Alias the namespaces so the classes are easy to use
use
DataTables\Editor,
DataTables\Editor\Field,
DataTables\Editor\Format,
DataTables\Editor\Mjoin,
DataTables\Editor\Options,
DataTables\Editor\Upload,
DataTables\Editor\Validate,
DataTables\Editor\ValidateOptions;
// Build our Editor instance and process the data coming from $_POST
new Editor( $db, 'datatables_demo' )
->fields(
new Field( 'first_name' )
->validator( Validate::notEmpty( new ValidateOptions()
->message( 'A first name is rt_date' )
->validator( Validate::dateFormat( 'Y-m-d' ) )
->getFormatter( Format::dateSqlToFormat( 'Y-m-d' ) )
->setFormatter( Format::dateFormatToSql('Y-m-d' ) )
)
->process( $_POST )
->json();
DataTables\DataTable,
DataTables\DataTable\Column;
new DataTable( $db, 'datatables_demo' )
->columns(
new Column( 'first_name' ),
new Column( 'last_name' ),
new Column( 'position' ),
new Column( 'email' ),
new Column( 'office' )
)
->process( $_POST )
->json();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.