smarty 对数据库的简单操作。

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 对数据库的简单操作。的更多相关文章
- Python --链接MYSQL数据库与简单操作 含SSH链接
项目是软硬件结合,在缺少设备的情况,需要通过接口来模拟实现与设备的交互,其中就需要通过从数据库读取商品的ID信息 出于安全考虑 现在很多数据库都不允许通过直接访问,大多数是通过SSH SSH : 数 ...
- 使用spring框架的JdbcTemplate实现对Oracle数据库的简单操作实例
最近实现了一个小功能,针对Oracle数据库两张关联表进行查询和修改,因为比较简单,所以选择了spring框架里的JdbcTemplate.JdbcTemplate算是老古董了,是当年spring为了 ...
- 在php中需要用到的mysql数据库的简单操作
1.数据库连接 1.1用windows命令行链接数据库服务器 几个DOS命令 在DOS环境下命令后面没有分号,在MySQL环境下,命令后面有分号 进入盘符: 语法:盘符: 进入盘符下的某个文件夹 语法 ...
- 用C#对ADO.NET数据库完成简单操作
数据库访问是程序中应用最普遍的部分.随着C#和ADO.NET的引入,这种操作变得更简单.这篇文章将示范四种最基础的数据库操作. ● 读取数据.其中包括多种数据类型:整型,字符串,日期型. ● 写数据. ...
- sqlite数据库之简单操作
一 sqlite介绍 Sqlite是一种嵌入式数据库,类似于一个文件系统,是跟程序在一起的.跟mysql等数据库程序跟数据分离是不一样的. 应用场景:常用于保存本地配置,类似于本地文件系统,因此他内嵌 ...
- 【MySQL】初识数据库及简单操作
一.数据库概述 1.1 什么是数据(Data) 描述事物的符号记录称为数据,描述事物的符号既可以是数字,也可以是文字.图片,图像.声音.语言等,数据由多种表现形式,它们都可以经过数字化后存入计算机. ...
- C#连接SQL Server数据库进行简单操作
环境:VS2010 + SqlServer 2008 首先,按照面向对象的程序设计思想,设计一个数据库操作工具类MyTool.cs,该类中封装了关于数据库连接和操作的方法,各个功能模块在需进行数据库操 ...
- Java连接MySQL数据库及简单操作代码
1.Java连接MySQL数据库 Java连接MySql需要下载JDBC驱动MySQL-connector-java-5.0.5.zip(举例,现有新版本).然后将其解压缩到任一目录.我是解压到D盘, ...
- python+mysql数据库的简单操作
最近接了一个任务,测试某项类似于收益情况报表的功能,因计算公式复杂,单纯手算过于复杂,所以想到写成脚本 根据python的分治原则,先整了几个函数用于实现计算逻辑,后发现数据输入过于繁琐,所以决定使用 ...
随机推荐
- 优秀技术Leader应具备的六项能力
技术Leader是互联网公司中,战斗在一线的技术领导者,技术Leader们能力的强弱,决定着公司整个技术团队的战斗力,结合我之前管理上百人技术团队的经验,谈谈我心目中优秀技术Leader五个方面的能力 ...
- 如何在jupyter中安装R
地址:(http://irkernel.github.io/installation/) 第一步:在R中安装必备包 install.packages(c('repr', 'IRdisplay', 'e ...
- 解决echarts的叠堆折线图数据出现坐标和值对不上的问题
原文:https://blog.csdn.net/qq_36538012/article/details/88889545 ------------------------------- 说一个小bu ...
- CSS3媒体查询实例
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- halcon导出类---HDevWindowStack详解
在HDevelop中编写好的程序在导出时,Halcon会帮我们转换成我们需要的语言,比如C++.例:HDevelop中有如下语句需要导出: dev_close_window() Halcon导出成C+ ...
- Cannot modify resource set without a write transaction 问题
TransactionalEditingDomainImpl editingDomain = (TransactionalEditingDomainImpl) diagramEditor.getEdi ...
- 程序装载:“640K内存”真的不够用么?
本文源于size_t的说明,看到比尔盖茨说过:640K内存对于任何人来说都足够了,所以找了一篇文章,学习一下~~ 一直以来都知道自己有关计算机底层的知识不是不扎实,前段时间跟着大佬们推荐在[极客时间] ...
- 解决Android SDK更新慢
SDK Manager -> tools -> options: HTTP Proxy Server: mirrors.neusoft.edu.cn HTTP Proxy Port: 80 ...
- Start Failed, Internal error: recovering IDE to the working state after the critical startup error
Start Failed, Internal error: recovering IDE to the working state after the critical startup error F ...
- 解决InputStream中数据读取不完整问题
转载:https://blog.csdn.net/lilidejing/article/details/37913627 当需要用到InputStream获取数据时,这时就需要读取InputStrea ...