Using PHP and Smarty Template Technology raw page static page code

Source: Internet
Author: User
Lear_all_cache ()//Clear All caches

<?php
smarty.php
Create HTML file Use Smarty template
Rossy.cn@gmial.com
2007-07-27 11:15

Require_once ("classes/smarty.class.php"); Smarty File
Require_once ("config.php"); Configuration file
Require_once ("mysql_class.php"); Database connection files

$smarty = new Smarty ();
$smarty->template_dir = "Templates";
$smarty->compile_dir = "Templates_c";
$smarty->left_delimiter = "<{";
$smarty->right_delimiter = "}>";

$page _count = "3"; Number of records per page
$Db = new Mysql;
$query = $Db->query ("SELECT * Tablea order Byid DESC");
$tatol = $Db->fetchcount ($query);
$pages = Ceil ($tatol/$page _count);
for ($j =1; $j <= $pages; $j + +)
$showpages. = "<ahref=\" User_ ". $j.". Htm\ ">". $j. " </a> ";

for ($i = 0; $i < $pages; $i + +)
{
$start _page = $i * $page _count;
if ($pages >1)
{
$indexpath = "User_". ($i + 1). ".  HTM "; FileName
$showpagestr = "<ahref=\" user_1.htm\ "> First page </a>". $showpages. "<ahref=\" User_ ". $pages." Htm\ "> Most last </a>";
}
Else
{
$indexpath = "user.htm"; File name
$showpagestr = "";
}

$sql = "SELECT * from Tableaorder by ID DESC LIMIT $start _page, $page _count";
$query = $Db->query ($sql) or Die ("Invalid query");
if (($Db->fetchcount ($query)) <1) {
$Admin = "The data library does not have this data";
}else{
while ($rs = $Db->fetcharray ($query)) {
$Admin [] =array (' id ' => $rs [' id '], ' name ' => $rs [' name '], ' Nick ' => $rs [' Username '], ' type ' => $rs [' type '], ' Email ' => $rs [' email ']];
}
}

$smarty->assign (Array (' Site_Name ' => "system", ' AdminName ' => ' ybfqlyq ', ' admintype ' => ' Administrator ', ' Type ') => ' 1 '));
$smarty->assign (' Admin ', $Admin);
$smarty->assign (' Page_str ', $showpagestr);
$temp = $smarty->fetch (' Test.tpl ', NULL, NULL, FALSE);//Template file
Unset ($Admin);
$showpagestr = "";
$FP =fopen ($indexpath, ' w ');
Fwrite ($fp, $temp) Ordie (' Create failed ');
}
$Db->close ();
echo "Create HTM file successfully";
?>

TEST.TPL File Code:
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01transitional//en" "HTTP://WWW.W3C.ORG/TR/1999/REC-HTML401-19991224/LOOSE.DTD" >
<!--saved Fromurl= (0046) http://localhost/overseatrade/keyword/user.php-->
<meta http-equiv=content-type content= "Text/html;charset=utf-8" ><link
href= "Templates/css.css" type=text/cssrel=stylesheet>
<meta content= "MSHTML 6.00.2900.2722" name=generator>
<style type= "Text/css" >
<!--
. style1 {
font-size:18px;
Font-weight:bold;
}
-->
</style>
</HEAD>
<BODY>
<table cellspacing=0 cellpadding=0 width= "90%" border=0>
<TBODY>
<TR>
&LT;TD height= "class=tipsstyle1><spanclass=" Style1 ">example of Create HTML file Usesmarty template with PHP </span></TD>
</TR>
</TBODY></TABLE>
<table class=tablestyle= "Word-break:break-all" bordercolor= #000000
cellspacing=0 cellpadding=2 width= "100%" Align=center border=1>
<TBODY>
<trclass= "Red1bg_head1" >
&LT;TD class=linebg1 align=middle> Number </TD>
&LT;TD class=linebg1 align=middle> User name </TD>
&LT;TD class=linebg1 align=middle> name </TD>
&LT;TD class=linebg1align=middle> Types </TD>
&LT;TD class=linebg1align=middle> Email Address </TD>
</TR>
<{sectionname=adminlist loop= $Admin}><trclass= "linebg<{$Bg _type}>1" >
<TDalign=middle> <{$Admin [adminlist]. Id}></td>
<TDalign=middle> <{$Admin [adminlist]. Name}></td>
<TDalign=middle> <{$Admin [adminlist]. Nick}></td>
<TDalign=middle> <{$Admin [adminlist]. Type}></td>
&LT;TD align=middle> <aclass=b
href= "mailto:<{$Admin [adminlist]. Email}> "><{$Admin [adminlist]. Email}></a></td>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.