昨天写了一个最简单的smarty文件,今天我就进一步学习,现在把学习的东西分享一下.首先.我们来看one.tpl文件.
this is my the <{$first}> smarty!
<{foreach from=$newsArray item=newsID}>
group_id:<{$newsID.id}>
group_name:<{$newsID.group_name}>
group_time:<{$newsID.group_time}>
group_auth:<{$newsID.group_auth}>
<{foreachelse}>
no infomation
<{/foreach}>
这里就用到foreach
下面再来看看smarty.php文件,
include_once("Smarty/libs/Smarty.class.php");
include_once("../inc/connect.php");
$smarty =new Smarty();
$smarty->template_dir ='Smarty/template';
$smarty->compile_dir ='Smarty/template_c';
$smarty->left_delimiter ='<{';
$smarty->right_delimiter='}>';
$sql ="select * from gx_user_group order by id desc";
$result =mysql_query($sql);
while( $rs=mysql_fetch_array($result))
{
$array[]=array('id'=>$rs['id'],'group_time'=>$rs['group_time'],'group_name'=>$rs['group_name'],'group_auth'=>$rs['group_auth']);
$smarty->assign('newsArray',$array);//最主要的是这一句了,因为smarty必须用数组它才会正常识别并读出
}
unset($array);
$smarty->display('one.tpl');
樱花校园模拟器4399中文版
樱花校园模拟器4399中文版,十分奇趣好玩的3d校园冒险模拟
我的暑假秘密回忆繁星新春版
我的暑假秘密回忆繁星新春版是一款少女模拟养成类休闲游戏。这款
樱花校园模拟器国际版
樱花校园模拟器国际版,一个超级自由超级好玩的自由恋爱模拟的游
饥荒海难九游版
饥荒海难九游版,带你去真实的海岛上感受一下什么才是真正的孤岛
盖瑞模组体验版最新版
盖瑞模组体验版是玩法非常丰富多元化的沙盒建造游戏,玩家可以在