<?php
/**
* Binds product data to HTML rendering
*/
class ProductView {
/**
* Private
* $model an instance of the ProductModel class
*/
var $model;
/**
* Private
* $output rendered HTML is stored here for display
*/
var $output;
//! A constructor.
/**
* Constucts a new ProductView object
* @param $model an instance of the ProductModel class
*/
function ProductView (&$model) {
$this->model=& $model;
}
//! A manipulator
/**
* Builds the top of an HTML page
* @return void
*/
function header () {
$this->output=<<<EOD
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> Our Products </title>
<style>
body { font-size: 13.75px; font-family: verdana }
td { font-size: 13.75px; font-family: verdana }
.title { font-size: 15.75px; font-weight: bold; font-family: verdana }
.heading {
font-size: 13.75px; font-weight: bold;
font-family: verdana; background-color: #f7f8f9 }
.nav { background-color: #f7f8f9 }
</style>
</head>
<body>
<div align="center" class="title">Our Products</div>
EOD;
$this->output.="\n<div align=\"right\"><a href=\"".
$_SERVER['PHP_SELF']."\">Start Over</a></div>\n";
}
//! A manipulator
/**
* Builds the bottom of an HTML page
* @return void
*/
function footer () {
$this->output.="</body>\n</html>";
}
//! A manipulator
/**
* Displays a single product
* @return void
*/
function productItem($id=1) {
$this->model->listProduct($id);
while ( $product=$this->model->getProduct() ) {
$this->output.="<p><b>Name</b>:".$product['PRODUCTNAME']."</p>".
"<p><b>Price</b>:".$product['UNITPRICE']."</p>".
"<p><b># In Stock</b>:".$product['UNITSINSTOCK']."</p>";
if ( $this->$product['DISCONTINUED']==1 ) {
$this->output.="<p>This product has been discontinued.</p>";
}
}
}
//! A manipulator
/**
* Builds a product table
* @return void
*/
function productTable($rownum=1) {
$rowsperpage='20';
$this->model->listProducts($rownum,$rowsperpage);
$this->output.="<table width=\"600\" align=\"center\">\n<tr>\n".
"<td class=\"heading\">Name</td>\n".
"<td class=\"heading\">Price</td>\n</tr>\n";
while ( $product=$this->model->getProduct() ) {
$this->output.="<tr>\n<td><a href=\"".$_SERVER['PHP_SELF'].
"?view=product&id=".$product['PRODUCTID']."\">".
$product['PRODUCTNAME']."</a></td>".
"<td>".$product['UNITPRICE']."</td>\n</tr>\n";
}
$this->output.="<tr class=\"nav\">\n";
if ( $rownum!=0 && $rownum > $rowsperpage ) {
$this->output.="<td><a href=\"".$_SERVER['PHP_SELF'].
"?view=table&rownum=".($rownum-$rowsperpage).
"\"><< Prev</a></td>";
} else {
$this->output.="<td> </td>";
}
if ( $product['PRODUCTID'] < ($rownum + $rowsperpage) ) {
$this->output.="<td><a href=\"".$_SERVER['PHP_SELF'].
"?view=table&rownum=".($rownum+$rowsperpage).
"\">Next >></a></td>";
} else {
$this->output.="<td> </td>\n";
}
$this->output.="</tr>\n</table>\n";
}
//! An accessor
/**
* Returns the rendered HTML
* @return string
*/
function display () {
return $this->output;
}
}
?>
没有合适的资源?快使用搜索试试~ 我知道了~
PHP的MVC实现_代码
共6个文件
php:5个
sql:1个
5星 · 超过95%的资源 需积分: 10 129 下载量 122 浏览量
2008-09-02
11:29:39
上传
评论 3
收藏 12KB ZIP 举报
温馨提示
PHP的MVC实现代码 PHP的MVC实现代码 PHP的MVC实现代码 PHP的MVC实现代码 PHP的MVC实现代码
资源推荐
资源详情
资源评论
收起资源包目录
PHP的MVC实现_代码.zip (6个子文件)
mvc
index.php 374B
sql
products.sql 90KB
lib
ProductController.php 877B
ProductView.php 4KB
DataAccess.php 1KB
ProductModel.php 1KB
共 6 条
- 1
poniuzai
- 粉丝: 0
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
前往页