|
本文介绍了php中使用smarty模板引擎生成静态页面的方法,以及php实现文章分页的实现代码,需要的朋友参考下。
例子,php中smarty生成静态页、文章内分页代码。专题:php分页代码原理
<?php
include "../config.php";
checkLogin ();
if (isset ($_GET['act']) && $_GET['act'] == 'add') {
// var_dump ($_POST);
$title = isset ($_POST['title']) ? trim ($_POST['title']) : '';
$tag = isset ($_POST['tag']) ? trim ($_POST['tag']) : '';
$content = isset ($_POST['content']) ? $_POST['content'] : '';
$create_time = time ();
echo $sql = "INSERT INTO `article` (`title`,`tag`,`content`,`create_time`) VALUES ('{$title}','{$tag}','{$content}','{$create_time}')";
$_POST['create_time'] = $create_time ;
$res=mysql_query ($sql);
$article_id = mysql_insert_id();
$file_name = '../html/'.$article_id.'.html';
if ($res) {
$temp = explode ('<div style=\"page-break-after: always;\"><span style=\"display: none;\"> </span></div>',$content);
$num = 0;
foreach ($temp as $key => $val ) {
$num++;
$pagenav = '';
if ($key == 0) {
$file_name = '../html/'.$article_id.'.html';
} else {
$file_name = '../html/'.$article_id.'_'.($key+1).'.html';
}
for ($i=1;$i<=count($temp);$i++)
{
if (($key+1) == $i)
{
$pagenav .= " <b>{$i}</b> ";
}
else
{
if ($i == 1)
{
$pagenav = $pagenav." {$i} ";
}
else
{
$pagenav .= " {$i} ";
}
}
}
$_POST['content'] = $val ;
$tpl->assign ('a',$_POST);
$tpl->assign ('pagenav',$pagenav);
$html = $tpl->fetch('show_article.html');
$fp=fopen ($file_name,'w');
if ($fp) {
fwrite ($fp,$html);
fclose ($fp);
}
}
alert ("生成{$num}篇成功",'add_article.php');
} else {
alert ('增加失败!');
}
} else {
//$FCK->Value='fanglor is a boy !';
$editer = $FCK->CreateHtml();
$tpl->assign ('editer',$editer);
$tpl->display ('add_article.html');
}
?>
登录后复制 生成静态页面的相关文章:
文章分页的相关文章:
MediPro网上书店系统
查看详情
基于PHP+MYSQL开发,除了网上书店必备的商品管理、配送支付管理、订单管理、会员分组、会员管理、查询统计和多项商品促销功能,还具有完整的文章、图文、下载、单页、广告发布等网站内容管理功能。系统具有静态HTML生成、UTF-8多语言支持、可视化模版引擎等技术特点,支持多频道调用不同模版和任意设置频道首页,适合建立各种规模的网上书店。系统具有以下主要功能模块: 网站参数设置 - 对网站的一些参数进
3
|
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号