HTML Table Class |
Hi
Could you please help me to fix the problem with HTML Table Class. I'm trying to generate a HTML table from the results of DB query. My query runs in Model and then I'm passing the results of function to the controller by the return $query->result();. And unfortunately table->generate give's Error 500 in this case. I did some tests and found out that probaly the problem in structure of the array which table->generate gets. As when I passing the results from the model to Controller with return $query->result_array(); table->generate build the table, but without headers. So the questions are: 1. Why table->generate doesn't work in first case 2. How should I send the data to table->generate so it will build the table with headers. Below you can find code I used and dumps of Arrays: Model: PHP Code: <?php Controller PHP Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); View PHP Code: <?php Dumps of $data array: return $query->result_array(); (table was generated but without the headings) PHP Code: array(1) { return $query->result(); Table generation failed with Error 500 PHP Code: array(1) {
Why don't you try to make it without using the table library ?
Its just 1 loop of data like: Code: <table> Best VPS Hosting : Digital Ocean
How big is your result data? Maybe your server geht a timeout by printing the table html. For debuggin try to do a simple loop or the example from sv3tli0:
PHP Code: <?php foreach($results as $entry): ?> I never used the table helper and i think he runs in memory error.
Ok, so I solved the problem by returning function result from Model to Controller with return $query->result and then just getting the header from this array and passing them to $this->table->set_heading() class:
PHP Code: $data["query"] = $this->model_getstats->getData_CBsales(); Maybe somebody will find it useful: |
Welcome Guest, Not a member yet? Register Sign In |