A personal story. Not going too deep on technicalities.
<?php
include "path/to/db_con.php";
$res = mysql_query("SELECT * FROM users ORDER BY " . $_GET['order'] . " LIMIT 100");
echo '<table>';
while ($user = mysql_fetch_assoc($res)) {
echo '<tr>';
echo "<td>$user[name]</td><td>$user[age]</td><td>";
if ($user['sex'] == 1) {
echo "Male";
} else {
echo "Female";
}
echo "</td>";
}
echo "</table>";
<table>
<?php foreach ($users as $user):?>
<tr>
<td><?=$user['name']?></td>
<td><?=$user['age']?></td>
<td><?=($user['age'] == 1 ? 'Female' : 'Male')?></td>
</tr>
<?php endforeach;?>
</table>
A view can be any output representation of information, such as a chart or a diagram. Multiple views of the same information are possible, such as a bar chart for management and a tabular view for accountants.
The model is the central component of the pattern. It expresses the application's behavior in terms of the problem domain, independent of the user interface.[6] It directly manages the data, logic and rules of the application.
The third part or section, the controller, accepts input and converts it to commands for the model or view
The controller is responsible for responding to the user input and perform interactions on the data model objects. The controller receives the input, it validates the input and then performs the business operation that modifies the state of the data model
... so many of them, doing the exact same thing ...
By Trygve Reenskaug - Trygve Reenskaug, CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=31168223
Something that is of interest to the user. It could be concrete, like a house or an integrated
circuit. It could be abstract, like a new idea or opinions about a paper. It could be a whole,
like a computer, or a part, like a circuit element
Models represent knowledge. A model could be a single object (rather uninteresting), or it
could be some structure of objects.
A Model is an active representation of an abstraction in the form of data in a computing
system
A view is attached to its model (or model part) and gets the data necessary for the presentation
from the model by asking questions...
To any given Model there is attached one or more Views, each View being capable of
showing one or more pictorial representations of the Model on the screen and on hardcopy.
... the view will therefore have to know the semantics of the attributes of the model it represents.
A controller is the link between a user and the system. It provides the user with input by
arranging for relevant views to present themselves in appropriate places on the screen. It
provides means for user output by presenting the user with menus or other means of giving
commands and data.
A controller should never supplement the views...
Conversely, a view should never know about user input, such as mouse operations and
keystrokes.