| 1 |
Introduction
|
Introduction
|
10
|
A loosely coupled MVC approach:
The model:
products.crtable.sql:
create table products (
id int auto_increment,
catNo varchar(255),
name varchar(255),
price double,
primary key(id)
)
The view:
products.tpl:
<html>
<head>
<title>{$title}</title>
</head>
<body>
<table>
{foreach from=$products item=product}
<tr>
{foreach from=$product item=$attribute}
<td>
{$attribute}
</td>
{/foreach}
</tr>
{/foreach}
</table>
</body>
</html>
The controller:
index.php:
<?
require_once("config.php");
$m = new Mmodel();
$v = new Mview();
$c = new Mcontroller($m, $v);
$products = $c->m->getAssoc("select * from products");
$c->v->showTpl("products.tpl", array('products' => $products, 'title' => 'A loosly coupled MVC approach',));
?>
|
Edit
|
New
|
Delete
|