喜悦国际村 
» 游客:  注册 | 登录 | 搜索 | 统计 | 喜悦证交所 | 帮助

RSS 订阅当前论坛  

$5.95 Web Hosting     

上一主题 下一主题
     
标题: smarttemplate模板问题!  
 
dzy (dzy)
注册会员
Rank: 2
一般会员


UID 64807
精华 0
积分 83
帖子 74
金钱 83 喜悦币
威望 0
人脉 0
阅读权限 20
注册 2005-6-17
状态 离线
[广告]: 代充Paypal帐号美元
smarttemplate模板问题!

ndex.php
<?php
require_once "smart/class.smarttemplate.php";
require_once "mysql.php";
$classId=$_GET["classId"];
$sql="select id,classname from newsclass order by id desc";
$res=@mysql_query($sql);
if(!$res)
{
echo "sql语句有错错误信息如示:<br>".mysql_error();
exit;
}
$tp=new SmartTemplate('index.tpl');
$path=$_SERVER['DOCUMENT_ROOT'];
$tp->template_dir='tpl/';
$tp->temp_dir=$path.'phpnews/compiled';
$tp->cahe_dir=$path.'phpnews/file/';
$tp->cahe_leftime=120;
$webtitle='dzy news center';
$arr = array();
while($rs=mysql_fetch_row($res))
{
$arr[]=array(
array(
'Id' => $rs[0],
'ClassName' => $rs[1],
)
);
}
$tp->assign('title',$webtitle);
$tp->assign('classname',$arr);
$tp->output();
?>
index.tpl
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>{title}</title>
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
-->
</style></head>

<body>
<table width="750" border="0" align="center" cellpadding="0" cellspacing="1">
<tr>
<td><table width="100%" border="0" cellspacing="1" cellpadding="0">
<tr>
<!---BEGIN classname--->
<td width="10%"><div align="center"><a href="index.php?classId={Id}">{ClassName}</a></div></td>
<!---END classname--->
</tr>
</table></td>
</tr>
</table>
</body>
</html>
就是替换不了!
我刚接触模板引擎
2006-7-28 05:22 PM#1
查看资料  发短消息  QQ  顶部
 
cutejing
新手上路
Rank: 1
老会员



UID 28423
精华 0
积分 5
帖子 503
金钱 5 喜悦币
威望 0
人脉 0
阅读权限 10
注册 2004-5-10
来自 流浪的人无定居所
状态 离线
[广告]: Enom域名自助付费 自助注册 自助PUSH 主流域名COM等一律57.99元年
应该是这样的 .... #76 .

<?php
while($rs=mysql_fetch_row($res))
{
$arr[]=array(
'Id' => $rs[0],
'ClassName' => $rs[1]
);
}
?>




the balance between love and like
2006-7-28 05:32 PM#2
查看资料  Blog  发短消息  顶部
 
dzy (dzy)
注册会员
Rank: 2
一般会员


UID 64807
精华 0
积分 83
帖子 74
金钱 83 喜悦币
威望 0
人脉 0
阅读权限 20
注册 2005-6-17
状态 离线
[推荐阅读] 请问:如何删除文本里的空格行?
这种方法我也试过!也不行!
我把模板文件改成
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>{title}</title>
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
-->
</style></head>

<body>
<table width="750" border="0" align="center" cellpadding="0" cellspacing="1">
<tr>
<td><table width="100%" border="0" cellspacing="1" cellpadding="0">
<tr>
<!---BEGIN classname--->
<td width="10%"><div align="center"><a href="index.php?classId={class.Id}">{classname.Name}</a></div></td>
<!---END classname--->
</tr>
</table></td>
</tr>
</table>
</body>
</html>
在就循环数组也改成楼主那种!也还是替换不了!
2006-7-28 05:44 PM#3
查看资料  发短消息  QQ  顶部
 
cutejing
新手上路
Rank: 1
老会员



UID 28423
精华 0
积分 5
帖子 503
金钱 5 喜悦币
威望 0
人脉 0
阅读权限 10
注册 2004-5-10
来自 流浪的人无定居所
状态 离线
[推荐阅读] 新手问题~~大虾帮帮我
#83....
#83....#83...#83....
你的 <!-- BEGIN -->
       <!-- END -->错了 ....




the balance between love and like
2006-7-28 05:47 PM#4
查看资料  Blog  发短消息  顶部
 
姜运涛
金牌会员
Rank: 6Rank: 6


UID 64643
精华 0
积分 1450
帖子 1333
金钱 1449 喜悦币
威望 0
人脉 1
阅读权限 70
注册 2005-6-8
来自 大连
状态 离线
[推荐阅读] 问一firefox下的问题.
<!-- BEGIN classname -->
注意格式
2006-7-29 03:23 AM#5
查看资料  Blog  发短消息  QQ  Yahoo!  顶部
 
游戏人间
版主
Rank: 7Rank: 7Rank: 7
☞风云山庄大少爷☜


UID 62639
精华 2
积分 14533
帖子 7514
金钱 14384 喜悦币
威望 20
人脉 129
阅读权限 100
注册 2004-12-21
来自 广西人在北京
状态 离线
[推荐阅读] 上海诚聘网页设计师和php程序员
你們說模板的東西我只能遠遠的站一邊.



 
群号:6025396/6025252/19520091(广西PHP交流/PHP高级编程/算法交流) 寧可在嘗試中失敗,也不在保守中成功! 不為失敗找理由,只為成功找方法! 饿踢Blog
 
2006-7-29 09:53 AM#6
查看资料  访问主页  Blog  发短消息  顶部
     


  可打印版本 | 推荐给朋友 | 订阅主题 | 收藏主题 | 开通个人空间  


 




Powered by Discuz! 6.1.0  © 2001-2010 Comsenz Inc.
Processed in 0.029696 second(s), 6 queries

(冀ICP备05009913号) 管理员:sadly 邮箱/MSN: sadly@phpx.com QQ:824008(长隐) 清除 Cookies - - Archiver - WAP