无为清净楼资源网 Design By www.qnjia.com

本文讲述了smarty简单应用实例。分享给大家供大家参考,具体如下:

<"smarty/templates/templates";
$smarty->compile_dir="smarty/templates/templates_c";
$smarty->config_dir="smarty/templates/config";
$smarty->cache_dir="smarty/templates/cache"; 
$hello = "Hello World!";
$smarty->compile_check = true;
//$smarty->debugging = true;
$smarty->debugging = false;
$smarty->caching=true;
$conn=mysql_connect("localhost", "root","root"); //打开MySQL服务器连接
mysql_select_db("lava_guess"); //链接数据库
mysql_query("set names utf8"); //解决中文乱码问题
$sql_list="Select * from t_sys_msg Order by id desc limit 0,10";
$result_list=mysql_query($sql_list); //执行sql语句,返回结果
//把记录集转换为数组
while($rs_list=mysql_fetch_array($result_list)) 
{
   $msg_array[]=$rs_list;
}
$array[] = array("newsID"=>1, "newsTitle"=>"第1条新闻"); 
$array[] = array("newsID"=>2, "newsTitle"=>"第2条新闻"); 
$array[] = array("newsID"=>3, "newsTitle"=>"第3条新闻"); 
$array[] = array("newsID"=>4, "newsTitle"=>"第4条新闻"); 
$array[] = array("newsID"=>5, "newsTitle"=>"第5条新闻"); 
$array[] = array("newsID"=>6, "newsTitle"=>"第6条新闻");
$smarty->assign("newsArray", $array);
$smarty->assign("hello",$hello);
//赋值
$smarty->assign("msglist",$msg_array);
$smarty->display('index.tpl');
"htmlcode">
<html>
<head>
<metahttp-equiv="Content-Type" content="text/html;charset=utf-8">
<title>Smarty</title></head>
<body>
<hr>
{$hello}
<hr>
 {section name=loop loop=$msglist}
 id: {$msglist[loop].id}--{$msglist[loop].title}----{$msglist[loop].receiver}<br>
 {/section}
<hr>
{section name=loop loop=$newsArray}
新闻编号:{$newsArray[loop].newsID}<br>
新闻标题:{$newsArray[loop].newsTitle}<br><hr>
{sectionelse}
对不起,没有任何新闻输入!
{/section}

希望本文所述对大家基于smarty模板的php程序设计有所帮助。

标签:
smarty,简单应用

无为清净楼资源网 Design By www.qnjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无为清净楼资源网 Design By www.qnjia.com

稳了!魔兽国服回归的3条重磅消息!官宣时间再确认!

昨天有一位朋友在大神群里分享,自己亚服账号被封号之后居然弹出了国服的封号信息对话框。

这里面让他访问的是一个国服的战网网址,com.cn和后面的zh都非常明白地表明这就是国服战网。

而他在复制这个网址并且进行登录之后,确实是网易的网址,也就是我们熟悉的停服之后国服发布的暴雪游戏产品运营到期开放退款的说明。这是一件比较奇怪的事情,因为以前都没有出现这样的情况,现在突然提示跳转到国服战网的网址,是不是说明了简体中文客户端已经开始进行更新了呢?