日期:2013-05-06  浏览次数:20436 次

 站点结构
代码:
站点
  ┗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文件 --------
[复制此代码]CODE:<?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文件-------------------
[复制此代码]CODE:<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>   
 &n