模板
站点结构
代码:
站点
┗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: 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 $tags[$i] = "|{".$tags[$i]."}|";
}
return preg_replace($tags,$vals,$this->source_file);
}
}
}
?>
----------------index.htm文件-------------------
[复制此代码]CODE:
姓名
性别
年龄
email
{所有列表}
共有{总条数}条记录,显示{每页条数}条/页
{分页}
------------------list.htm文件-------------------
[复制此代码]CODE:
{姓名}
{性别}
{年龄}
{email}
-------------------content.htm文件-----------------------
[复制此代码]CODE:
姓名
{姓名}
性别
{性别}
年龄
{年龄}
email
{email}
-----index.php ファイル--------------------------
[このコードをコピーします]CODE: include("includes/class.inc");
$mycon =new mycon;
$con = $mycon->connect(); mysql_select_db("test",$con);
$lim = 20; //各ページに表示される行数
$p = ($_GET[p]) //現在のページ番号
/ ***** リストの生成を開始 *****/
$lists = "";
$tmpl->get_file("templet/list.htm");
$tags = array("メンバー ID", "名前", "性別", "Age","email"); //テーブルのフィールドと同じ順序である必要があります
$rs = mysql_query("select * from test order by id desc limit ".($p-1)*$lim .",$lim" );
while($row=mysql_fetch_row($rs)){
$lists .= $tmpl->parse($tags,$row) ;get_file("templet/index.htm") );
$rn = @mysql_result(mysql_query("select count(id) from test"),0); // 総レコード数
$ps = ceil($rn/$ lim);
$pagination = "ホームページ ";
if($p>1) $pagination .= "";
else $pagination .= "";
$pagination .= "前のページ ";
if($p";
else $pagination .= "";
$pagination .= "次のページ 最後のページ ; " );
$vals = array($lists,$rn,$lim,$pagination);
echo $tmpl->parse($tags,$vals);
?>
--- -- ---------- content.php ファイル --------------
[このコードをコピー]CODE: include("includes/class. inc");
$tmpl =新しいテンプルト; $mycon =新しい mycon;
mysql_select_db("test",$con); $tmpl->get_file( "templet/content.htm");
$rs = mysql_query("select * from test where id=$_GET[id]");
$row=@mysql_fetch_row($rs); ; tmpl->parse($tags?>)

ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

AI Hentai Generator
AIヘンタイを無料で生成します。

人気の記事

ホットツール

MantisBT
Mantis は、製品の欠陥追跡を支援するために設計された、導入が簡単な Web ベースの欠陥追跡ツールです。 PHP、MySQL、Web サーバーが必要です。デモおよびホスティング サービスをチェックしてください。

メモ帳++7.3.1
使いやすく無料のコードエディター

MinGW - Minimalist GNU for Windows
このプロジェクトは osdn.net/projects/mingw に移行中です。引き続きそこでフォローしていただけます。 MinGW: GNU Compiler Collection (GCC) のネイティブ Windows ポートであり、ネイティブ Windows アプリケーションを構築するための自由に配布可能なインポート ライブラリとヘッダー ファイルであり、C99 機能をサポートする MSVC ランタイムの拡張機能が含まれています。すべての MinGW ソフトウェアは 64 ビット Windows プラットフォームで実行できます。

PhpStorm Mac バージョン
最新(2018.2.1)のプロフェッショナル向けPHP統合開発ツール

SublimeText3 中国語版
中国語版、とても使いやすい
