Using HTML Table Class in a View - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Using HTML Table Class in a View (/showthread.php?tid=43548) |
Using HTML Table Class in a View - El Forum - 07-15-2011 [eluser]Unknown[/eluser] Hi, I'm new to Codeigniter and indeed the whole MVC structure, I'm learning fast but have come across an issue I just can't get my head round. Hoping someone can help! My aim at the moment is a simple enquiry into a database which is then automatically turned into a table and presented via a view. I can pass the data to the View and present it via a Foreach loop without any problems (see below code which works). However, I've spent hours now trying to use the table->generate() approach via the View and I just can't work out whether I'm supposed to run the command in the Model and pass it to a variable which goes to the View (via the Controller) or run the command in the Controller and pass it to a variable. I've tried both with no success. The only way I can get the table->generate to work is by echoing it from the Model or Controller which seems messy and not best practice. My code is below, at the moment it generates output via a Foreach, anyone who can show/tell me how to amend the code to use table->generate() properly is officially a legend! Thanks Tom Controller: Code: <?php Model: Code: <?php View: Code: <html> Using HTML Table Class in a View - El Forum - 07-15-2011 [eluser]LuckyFella73[/eluser] Just guessing - but try that as your model-code: Code: <?php Using HTML Table Class in a View - El Forum - 07-15-2011 [eluser]Unknown[/eluser] After all that I can't believe it was something so simple! Thank you very much indeed! Using HTML Table Class in a View - El Forum - 07-15-2011 [eluser]LuckyFella73[/eluser] Glad it works now! |