| 网站首页 | JAVA文章 | AppServers | Web开发 | 应用开发 | 资源下载 | 论坛
    学好外语能够获得更多的国外先进编程技术  [enadd  2006年12月25日]        
设为首页 加入收藏 联系站长
您现在的位置: 编程笔记网 >> Web开发 >> 网络编程 >> PHP编程 >> PHP基础教程 >> 文章正文
smarty实例教程〔转〕4        【字体:
smarty实例教程〔转〕4
作者:不祥    文章来源:-    点击数:    更新时间:2006-8-10

=============================================================
index.php
=============================================================
<?php
1. /*********************************************
*
* 文件名: index.php
* 作 用: 显示实例程序
*
* 作 者: 大师兄
* Email: teacherli@163.com
*
*********************************************/
2. include_once("./comm/Smarty.class.php"); //包含smarty类文件
3. define("NUM", 5); //定义每次显示的新闻条数

4. $smarty = new Smarty(); //建立smarty实例对象$smarty
$smarty->templates_dir = "./templates"; //设置模板目录
$smarty->compile_dir = "./templates_c"; //设置编译目录
$smarty->cache_dir = "./cache"; //设置缓存目录
$smarty->cache_lifetime = 60 * 60 * 24; //设置缓存时间
$smarty->caching = false; //这里是调试时设为false,发布时请使用true
$smarty->left_delimiter = "<{"; //设置左边界符
$smarty->right_delimiter = "}>"; //设置右边界符


5. $db = sql/Index.html'>mysql_connect("localhost", "root", "");
sql/Index.html'>mysql_select_db("News", $db);


//这里将处理国内新闻部分
6. $strQuery = "SELECT iNewsID, iNewsTitle FROM tb_news_CH ORDER BY iNewsID DESC";
$result = sql/Index.html'>mysql_query($strQuery);
$i = NUM;
7. while(($row = sql/Index.html'>mysql_fetch_array($result)) && $i > 0)
{
$array[] = array("NewsID", substr($row["iNewsID"], 0, 40),
"NewsTitle", substr($row["vcNewsTitle"], 0, 40));

$i--;
}
8. $smarty->assign("News_CH", $array);
9. unset($array);
sql/Index.html'>my[1] [2] [3] [4] [5] [6] [7] [8] [9] 下一页  

文章录入:enadd    责任编辑:enadd 
  • 上一篇文章:

  • 下一篇文章:
  • 发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    最新热点 最新推荐 相关文章
  • smarty实例教程〔转〕1

  • smarty实例教程〔转〕2

  • smarty实例教程〔转〕3

  • 十天学会php之第七天

  • 十天学会php之第一天

  • 十天学会php之第二天

  • 十天学会php之第三天

  • 十天学会php之第四天

  • 十天学会php之第六天

  • 十天学会php之第五天

  •   网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    | 设为首页 | 加入收藏 | 联系站长 | 友情链接 | 版权申明 | 管理登录 |