smarty 对数据库的简单操作。
2010-06-19 22:28
183 查看
smarty简单配置
-------------------------------------smarty_inc.php--------------------------------------------
<?php
include_once("./smarty/Smarty.class.php");
$smarty=new Smarty();
$smarty->config_dir="smarty/Config_File.class.php";//目录变量
$smarty->caching=false;//是否使用缓存
$smarty->template_dir="./templates";//设置模板目录
$smarty->compile_dir="./templates_c";//设置编译目录
$smarty->cache_dir="./smarty_cache";//缓存文件夹
$smarty->left_delimiter="{";
$smarty->right_delimiter="}";
?>
----------------------------------index.php---------------------------------------------------
<?php
include("config.php");
$sql=mysql_query("select * from xinxi order by id desc");
while($row=mysql_fetch_array($sql)){
$arrdata[]=$row;
}
$smarty->assign("xx",$arrdata);
$smarty->display("index.htm");
?>
-----------------------------------index.htm 模板文件 主要操作 如何应用section循环二维数组--------------------------------------------
<?php include("config.php");?>
<html
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<hr />
<a href="">首页</a>|<a href="">流言</a>|
<hr />
<body>
<form action="" method="post" name="form2">
<table bgcolor="#FFFFCC" width="800" align="left" cellpadding="0" cellspacing="1">
<tr >
<tr>
<td align="center" width="50" height="20">标题
</td>
<td align="center" width="300" height="20">内容
</td>
<td align="center" width="100" height="20">留言时间
</td>
</tr>
{section name=list loop=$xx} //主要显示代码
<tr>
<td align="center" width="50">
<input name="del[]" type="checkbox" value="" />
</td>
<td align="center" width="50" height="20">{$xx[list].title}
</td>
<td align="left" width="300" height="20">{$xx[list].content}
</td>
<td align="center" width="100" height="20">{$xx[list].createtime}
</td>
</tr>
{/section}
</tr>
<tr>
<td width="6">
</td>
<td width="200" >
</td>
</tr>
</table>
</form>
</body>
</html>
相关文章推荐
- smarty 对数据库的简单操作。
- oracle跨数据库简单操作
- iOS-简单的数据库操作
- sqlmap 简单操作与数据库账户密码破解
- android简单的数据库使用查询操作示例
- MFC中简单的数据库文件操作(添加,修改,查找,删除)
- CoreData的简单使用<二、CoreData两张数据库表的关联操作>
- 利用C3P0数据源来作连接池,简单的写一个数据库操作来描述分层思想
- 写给初学者26_android_数据持久化_LitePal_更简单的数据库操作
- C++连接MySQL并简单操作数据库
- SQLiteDatabase里面的简单操作数据库的方法
- mysql简单数据库分表操作
- java从操作配置文件中连接数据库的简单写法
- 七.使用SQLiteOpenHelper类对数据库简单操作
- FMDB 数据库简单操作
- 一个简单的dbm数据库的实验-----dbm打开 存储 检索 删除 扫描操作的C代码
- smarty对数据库的基本操作
- Mybatis简单的操作数据库
- 自定义封装简单的基于FMDB以及数据model的数据库操作
- 使ASP.NET中的数据库操作变得简单