I have some html code with some php variables in it which describes the content of a single entry in my search results(e.g. picture, name, number of mutual friends etc) - this is referred to as search_results_v.php in my code below. I have an array which contains several records from a database, and for each one of these I make a search result entry. The way I have structured my program is an MVC, so the html code is the view and I have a php controller.
However I have a template for my website and would like to include my search results in this template. This could be solved easily by calling my controller in the appropriate part of this webpage, but I want to make my application so that the controller controls everything! In the case I just mentioned the view was calling the controller, but I want to have a setup like I have below, where I simply "include" the webpage in my controller.
How can I render my search results in the webpage while minimising the amount of php logic in it? One way I was considering doing this was to store all of the html code for all of the search results in a php string variable, and then just make a reference to this variable in my webpage. How could store the html code in that variable?
// Generates my search result box - Fill in the profile picture, the name and the number of mutual friends
foreach ($resultsInfo as $entry) {
$uid = $entry['uid'];
$pic_link = $entry['pic_square'];
$name = $entry['name'];
$mfCount = $entry['mutual_friend_count'];
include('searchresults_v.php');
}
EDIT: Ok, maybe what I was going for isn't an MVC exactly. I was trying to separate out the actual backend coding from the interface as much as I could so that someone far more adept could come in and design an interface. I basically wanted to generate all the dynamic data and just have some placeholders in my html files so that the content could just slip in. I didn't want there to be any logic in there to confuse someone who may only have experience with web design.
Let me know what I should change my title to.