In my controller I get all the entries from Athletes table, names, surnames etc... Save them in the array and pass them to my view. In my view file I then list all the entries using foreach . All the Athletes are listed fine...
However I want to check every Athlete and see if they exist in the table My Team! So in my foreach loop in my view I use this function
$this->my_team_model->exist($this->session->userdata("id"), $athletes[$i][6]) === TRUE
First parameter of exist() function is user id I get from session, second parameter is id of Athlete from Athletes table ($athletes[$i][6]).
So you see I really need that second Athlete id parameter! But I can only get it when the Athletes are listed one by one in my view. But I know I shouldn't use functions and logic in my view files. How can I do this in my controller?