站点结构
代码:
站点
┗includes
┗class.inc
┣templet
┗index.htm
┣list.htm
┗content.htm
┣index.php
┗content.php
库结构
代码:
-- 数据库: `test`
-- 表的结构 `test`
CREATE TABLE `test` (
`id` smallint(3) NOT NULL auto_increment,
`name` varchar(10) NOT NULL default '',
`sex` enum('男','女') NOT NULL default '男',
`age` smallint(2) NOT NULL default '0',
`email` varchar(20) NOT NULL default '',
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=1 ;
--------------- class.inc文件 --------
复制代码 代码如下:
<?php
class mycon{
private $myhost;
private $myuser;
private $mypwd;
function mycon($host="localhost",$user="root",$pwd=""){
$this->myhost = $host;
$this->myuser = $user;
$this->mypwd = $pwd;
}
function connect(){
return mysql_connect($this->myhost,$this->myuser,$this->mypwd);
}
}
class templet{
private $source_file;
function get_file($filename){
$this->source_file = file_get_contents($filename);
}
function parse($tags,$vals){
if(!is_array($tags)){
return preg_replace("|{".$tags."}|",$vals,$this->source_file);
}else{
$an = count($tags);
for($i=0;$i<$an;$i++){
$tags[$i] = "|{".$tags[$i]."}|";
}
return preg_replace($tags,$vals,$this->source_file);
}
}
}
?>
----------------index.htm文件-------------------
复制代码 代码如下:
<HTML>
<HEAD>
<TITLE>首页</TITLE>
</HEAD>
<BODY style="font-size:12px">
<TABLE WIDTH="100%" CELLPADDING="0" CELLSPACING="1" bgcolor=#000000 style="font-size:12px">
<caption>成员列表</caption>
<TR bgcolor="#ffffff" align=center>
<TD width=25%>姓名</TD>
<TD width=25%>性别</TD>
<TD width=25%>年龄</TD>
<TD width=25%>email</TD>
</TR>
{所有列表}
<TR bgcolor="#ffffff">
<TD colspan=2>共有{总条数}条记录,显示{每页条数}条/页</TD>
<TD colspan=2 align=right>{分页}</TD>
</TR>
</TABLE>
</BODY>
</HTML>
------------------list.htm文件-------------------
复制代码 代码如下: