php文件<?php
include("smarty_inc.php");
$con = mysql_connect("127.0.0.1","user","123456");
if (!$con)
die('Could not connect: ' . mysql_error());mysql_query("set names gbk");
mysql_select_db("test",$con);
$result=mysql_query("select * from my_db order by age");
while($row=mysql_fetch_assoc($result)){
$table[]=$row;
}
$smarty->assign('table',$table);
模板文件
{foreach from=$table key=myId item=i}
<li>id{$i.id}--姓名{$i.name}--年龄{$i.age}...</li>
{/foreach}
楼主够刻苦的,洗洗睡吧~
include("smarty_inc.php");
$con = mysql_connect("127.0.0.1","user","123456");
if (!$con)
die('Could not connect: ' . mysql_error());mysql_query("set names gbk");
mysql_select_db("test",$con);
$result=mysql_query("select * from my_db order by age");
while($row=mysql_fetch_assoc($result)){
$table[]=$row;
}
$smarty->assign('table',$table);
模板文件
{foreach from=$table key=myId item=i}
<li>id{$i.id}--姓名{$i.name}--年龄{$i.age}...</li>
{/foreach}
楼主够刻苦的,洗洗睡吧~
$smarty->assign('table',$table);
$smarty->display("模板文件");
在3.1.8里还多了个 smartyBC.Class.php 这个是干什么用了?if(!$method->is_cached("niu.tpl")) {
echo "没有缓存";
.......................
.......................
....//这里是读数据库.....
.......................
.......................}
echo "已有缓存";
$smarty->display("niu.tql")
直接不输出!!!!....