Interested in this question, for example, there are two tables in the database
News table
id title cat_id 1 Новость 1 3 2 Новость 2 2 3 Новость 3 1
Table categories
id title 1 Категория 1 2 Категория 2 3 Категория 3
And also created two models for working with their data tables (news_model and categories_model). The result is (as an example, I will give the latest news output) that, in the controller, I first turn to the method of the model news_model, which returns an array with the latest 10 news. Then IN THE CONTROLLER, I loop through the resulting array and form an array of category IDs. After that, I refer to the categories_model model method, which returns an array of a category by their identifiers. After that in the controller I form an array with data for output ($ result = [[news] => [....], [categories] => [....]]) and give this data into view. As a result, he (the view) returns the HTML code to the controller, and that in turn displays this code to the user.
So here. The question is as follows. How to organize it. It seems to me that it is not correct to go through the data loop in the controller, but I don’t know how to do it correctly.
MVC
they are no longer there any real number ... - And