An open API service indexing awesome lists of open source software.

https://github.com/hangsbreaker/atable

Ajax data table with php
https://github.com/hangsbreaker/atable

ajax-atable database mysqli pgsql php table

Last synced: 3 months ago
JSON representation

Ajax data table with php

Awesome Lists containing this project

README

          

# aTable
Responsive Ajax data table with php

This atable is automatic creating ajax table that data get from database

(Automatic Pagination, Sorting and Searching)

The atable can include parameter from outside variable

Support database (mysql, mysqli, pgsql) and joining table

# Initial atable
atable_init();

# Using
$atable = new Atable();

$atable->limit    // number limit data select (default 10)

$atable->limitfind   // number limit data after find (default 300)

$atable->query    // sql query string parameter (required)

$atable->where   // where string after query parameter (default empty)

$atable->orderby   // order by string after query parameter (default empty)

$atable->groupby   // group by string after query parameter (default empty)

$atable->col     // column name table in database (required)

$atable->colv    // column name view (visible in webpage as table column header) (required)

$atable->param   // php string inside one single quote ('') will be eval to atable

$atable->colnumber // show/hide column number boolean (default TRUE)

$atable->colsize    // column size of table as style (default empty)

$atable->colalign   // column align table as style L(left),R(right),C(center) (default align left)

$atable->showsql   // show query result boolean (default FALSE)

$atable->style     // modify table css class (default using bootstrap 3)

$atable->caption   // title of table (default empty)

$atable->reload=TRUE;

$atable->datainfo=FALSE;

$atable->paging=FALSE;

$atable->debug=FALSE;



echo $atable->load();


Tips:

- For search can use quotation. eg: "build 23"

- Use table column as variable in param then column can be sort

# Example
// need jquery

require atable.php // include or require the atable script

// ======================================================================================

// creating ajax atable

$atablea = new Atable();

$atablea->limit = 10;

$atablea->query = "SELECT m.nrp, m.nama, j.kode_jurusan, j.nama_jurusan, m.tahun_masuk FROM mahasiswa m, jurusan j";

$atablea->orderby = "m.tahun_masuk DESC, m.nama ASC";

$atablea->where = "m.kode_jurusan=j.kode_jurusan and m.tahun_masuk='$tahun'";

$atablea->col = "['nrp', 'nama', 'jurusan', 'tahun_masuk', '$td;']";

$atablea->colv = "['NRP', 'NAMA', 'JURUSAN', 'TH MASUK', 'TES']";

$atablea->colsize = "['100px', '', '','90px']";

$atablea->tdalign = "['R', 'L', 'L','R','L']";

$atablea->style = 'table table-hover';

$atablea->param = '$td="From param var";';

echo $atablea->load();

// ======================================================================================

// creating Second ajax atable

$atableb = new Atable();

$atableb->limit = 5;

$atableb->query = "SELECT * FROM mahasiswa";

$atableb->col = "['nrp', 'nama', 'kelamin']";

$atableb->colv = "['NRP', 'NAMA', 'JK']";

$atableb->colsize = "['110px', '', '20px']";

$atableb->showsql = TRUE;

echo $atableb->load();

/** NOTE:

** Please asign $_POST->databases before call atable.php if the Atable Unkown Database

** Example:

** $_POST->databases='mysql'; // for mysql database

** $_POST->databases='mysqli'; // for mysqli database

** $_POST->databases='pgsql'; // for pgsql database

** ===================================================

** $_POST["toatable"]=TRUE; // add this for send parameter to atable

**/