• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Display content in table

Hello, i have a doubt i get info at the db and i want to format it in a table in the view archive but i´m not convinced at the idea of put php code in the view, exists another way to do this?

[eluser]TWP Marketing[/eluser]
Do your formatting in a model, or in the controller and only send the formatted data to the view.
However, sometimes you must put php processing in a view, for instance a foreach() loop to write a list or html table. The code police will not be overly upset with this, because they do it themselves, sometimes...

Thanks for your fast reply!

As by design: How you present your data should be handled in the view. Therefore you need to use PHP to create your table (i.e. loop over the results and format them how you want it) in the view.

Grab the data in the controller by calling the model and send the data (probably an array of arrays or objects) to the view which will make a table, an ul/ol or something else out of it Wink

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.