I am new to Model-View-Controller and I started coding in Codeigniter. I am basically converting my project into MVC, however, I encountered this function(below) which I would like to split into MVC. I have 100s of functions like this and if I get the best approach to this, I will be able to convert the rest of my functions into MVC myself.
This function contains PHP, Mysql, and HTML everything in one. Like we split queries and HTML separately, I also want to do it using Codeingiter framework. Even if you cannot answer using codeigniter default functions, just tell me how to split.
Here it is :
$fetch_projections = mysql_query("SELECT issue_id, emp_name, employeeId, sum(actualHoursPerDay) as ss FROM day_projections WHERE date = '$today' GROUP BY employeeId ORDER BY emp_name ASC");
while ($r = mysql_fetch_array($fetch_projections)) {
$maes_array[] = $r['issue_id'];
$all_maes_for_emp = implode($maes_array);
// echo $r['emp_name'] $r['ss'].'<br/>';
$split_up_query = mysql_query("SELECT issue_id, actualHoursPerDay FROM day_projections WHERE date = '$today' AND emp_name = '" . $r['emp_name'] . "'");
while ($t = mysql_fetch_array($split_up_query)) {
$kk[] = $t['issue_id'] . ' = ' . $t['actualHoursPerDay'] . ' hrs';
}
$pp = implode(', ', $kk);
$cap = round((((8 - $r['ss']) / 8) * 100), 2);
echo '<tr><td>' . $r['emp_name'] . '</td><td>' . $cap . '%</td><td>' . $r['ss'] . ' hrs</td><td>' . $pp . '</td></tr>';
unset($maes_array);
unset($kk);
}
Thanks