, (*1)
HTMLtable
Use HTMLtable to create and show tables with pagination., (*2)
Made for Anax-MVC in the course phpmvc at BTH., (*3)
Use with Anax
Install
Add rcus/htmltable to your composer.json file with require., (*4)
"minimum-stability": "dev",
"require": {
...
"rcus/htmltable": "dev-master"
}
Run composer install --no-dev or composer update --no-dev to get rcus/htmltable. rcus/htmltable require mos/cdatabase and will install it for you. While mos/cdatabase is a dev version you need to set "minimum-stability": "dev"., (*5)
Tip: If you would like to test HTMLtable, copy htmltable.php from /vendor/rcus/htmltable/webroot to /webroot and point your browser to that file., (*6)
Usage
First we have to create a table object in your pagecontroller., (*7)
// Create a table object
$table = new rcus\HTMLTable\CHTMLTable(require ANAX_APP_PATH . 'config/database_sqlite.php');
You maybe have to edit the path and filename for your configuration of the database. If you do not have any config-file, copy from vendor/rcus/htmltable/webroot and edit (if needed). Read more about this at dbwebb., (*8)
If you would like to add some testdata to the table, add this:, (*9)
// Create tabledata
require ANAX_INSTALL_PATH . 'vendor/rcus/htmltable/webroot/includeCreateTableData.php';
Set up your table with the testdata we created above., (*10)
// Set options for table
$table->setTableOptions('test',
array(
'ID' => 'id',
'Förnamn' => 'firstname',
'Efternamn' => 'surname',
'Födelsedag' => 'birthdate'
));
'test' refers to the table name in the database. Then add the columns you want to include in your table in the array, where $key will be the column's title and $value is the column's name in the database., (*11)
Finally, create the table. The fun part..., (*12)
// Get the HTMLtable
$table->getHTML();
Well, it might not be that fun. But this line convert your table in the database to a HTML table., (*13)
About
Requirements
To-do list
- Specify which columns to order
- Make values clickable
- Make table cacheable
- Add some style (I know, it doesn't look that nice. But that's not a problem with your CSS-skills)
Author
Marcus Törnroth (m@rcus.se), (*14)
License
HTMLTable is licensed under the MIT License - see the LICENSE.txt file for details, (*15)