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>
<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" >
<TD class=linebg1 align=middle> Number </TD>
<TD class=linebg1 align=middle> User name </TD>
<TD class=linebg1 align=middle> name </TD>
<TD class=linebg1align=middle> Types </TD>
<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>
<TD align=middle> <aclass=b
href= "mailto:<{$Admin [adminlist]. Email}> "><{$Admin [adminlist]. Email}></a></td>