![]() |
How to do this with table class - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: How to do this with table class (/showthread.php?tid=26551) |
How to do this with table class - El Forum - 01-16-2010 [eluser]Bainzy[/eluser] Hello everyone, I'm a little stumped as to how to only return the cols I want from a database end show them with the table class here is what I have so far : $this->table->set_heading(array('forums', 'topics', 'posts', 'lastPost')); $data = $this->HomeModel->fetchAllRows('topics'); $this->table->generate($data); now the problem here is that my database has 5 rows in it and I only want to show the 4 that corrospond to the headers, how can I do this ? Regards chris How to do this with table class - El Forum - 01-16-2010 [eluser]Ben Edmunds[/eluser] This is probably the best way to do it but there are many ways to accomplish this: Code: $columns = array(‘forums’, ‘topics’, ‘posts’, ‘lastPost’); How to do this with table class - El Forum - 01-17-2010 [eluser]Bainzy[/eluser] Can you explain how this code work because at the moment only the headers are showing but there is no data ? How to do this with table class - El Forum - 01-17-2010 [eluser]Ben Edmunds[/eluser] Make sure that $this->HomeModel->fetchAllRows(‘topics’); is returning a multi-dimensional array. You might want to try a print_r() on the results of the method call to make sure it is returning the correct data as well. Here's the code with comments: Code: $columns = array(‘forums’, ‘topics’, ‘posts’, ‘lastPost’); //the fields you want / the columns in your table How to do this with table class - El Forum - 01-18-2010 [eluser]Bainzy[/eluser] hi again ben, This still appears not to be working, here is my code for the fetchAllRows statement : Code: // Fetch all rows If i use the code that i originally posted then this works so the data is definately there, my database column names also match that of the code you posted and still nothing i am just getting the headers coming up no problem however the data is missing. Is there something i am missing, i am also running the template library so sending values to my template is a little bit more awkward so i have made some minor adjustments to your code. Here is the code i have in my 'Home' Controller Code: // Lets create the content How to do this with table class - El Forum - 01-18-2010 [eluser]Bainzy[/eluser] Hey again, no need to answer my question now looks like i must have had a bug in the code as copied and pasted yours in and it worked even though i could not see anything wrong. Anyway thankyou for this code it was very helpful and i think i have got my head around how it works. Regard Chris |