CodeIgniter Forums
Where to put build table rows HTML? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Model-View-Controller (https://forum.codeigniter.com/forumdisplay.php?fid=10)
+--- Thread: Where to put build table rows HTML? (/showthread.php?tid=70990)



Where to put build table rows HTML? - hacksler - 06-25-2018

I'm new to CI and the MVC-Pattern, so i wonder where to put what. If i understand right, Controllers are primarilly used for routing the requests and stick results together for delivery and view should only contain static content.

In my application i would show the table by using a static part from the view, where all the HTM init-stuff is done (loading bootstrap css and stuff). Also there is the heading of the table.

I've create a model to access my data, which works fine so far.

Now i wonder where to read from database and transform the results into HTML-Tags. Should it be done in controller or in view?
Should i code it inside the view? I guess this would break the concept of separating business-logic and content... ir should it do it inside the controller?


RE: Where to put build table rows HTML? - php_rocs - 06-25-2018

@hacksler,

Have you tried the CI documentation? It has a good tutorial that can assist you in learning the MVC pattern: https://codeigniter.com/user_guide/tutorial/index.html


RE: Where to put build table rows HTML? - InsiteFX - 06-26-2018

Input        --> Processing --> Output 
Controller --> Model         --> View

SEE:  The Model-View-Controller (MVC) Design Pattern for PHP


RE: Where to put build table rows HTML? - donpwinston - 06-26-2018

(06-25-2018, 04:41 AM)hacksler Wrote: ...

Now i wonder where to read from database and transform the results into HTML-Tags. Should it be done in controller or in view?
Should i code it inside the view? I guess this would break the concept of separating business-logic and content... ir should it do it inside the controller?

You should not write much code in your view. It should just contain html and print statements and loops and if statements that directly outputs the presentation. 

In your controller you create whatever models you need and pass the data into the view where its rendered.