Table heading bug? |
02-11-2018, 04:27 AM
(This post was last modified: 02-11-2018, 04:05 PM by lokkook. Edit Reason: typos )
Hi,
I'm using CI 3.1.7, and trying to use properly the table library. I am executing a request (typically a SELECT *), and use this line to output HTML : PHP Code: echo $this->table->generate($textes_last); It successfully prints a HTML tab, with my data, by the heading row is the first set of data, and not the column titles as I expect, and as the documentation describe it. How can I use this library without having to use "set_heading()" manually ? Thanks a lot for your help !
@lokkook
You could approach this in many ways. One of those ways... create a method that not only returns the data from the select statement but also returns an array of the headers as well. i.e. [ 0 => selected data array, 1 => header array ] Then in the controller you can take the returned results and automatically set your html headers and create your html table. (02-12-2018, 10:23 AM)php_rocs Wrote: @lokkook Good idea... But to be clear : so the documentation seems to be wrong about the construction of the table ? The headings are not automatically created. Am I right ? I also found "Grocery CRUD", a library that could simplify a lot table/db manipulation.
Here is an example of a table created from a database query result. The table class will automatically generate the headings based on the table names (or you can set your own headings using the
Code: set_heading() method described in the class reference below). PHP Code: $this->load->library('table'); What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
|
Welcome Guest, Not a member yet? Register Sign In |