Smarty从数据库中提取图片显示到页面(实例)
2012-12-13 19:19
232 查看
PHP 文件:
<?php
include("libs/Smarty.class.php");
$smarty=new Smarty();
$smarty->template_dir="demo/templates";
$smarty->compile_dir="demo/templates_c";
$smarty->left_delimiter="<{";
$smarty->right_delimiter="}>";
$smarty->config_dir="demo/config";
//$smarty->caching=true;//开启缓存
//$smarty->cache_dir="../demo/cache";//缓存文件存放的路径
$array2=array();
mysql_connect("localhost","root","123");
mysql_select_db("fanyi");
mysql_query("set names utf8");
$q="select * from tupian order by id desc limit 1 ";
$result=mysql_query($q);
while($row=mysql_fetch_assoc($result)){
$array2[]=$row;
}
//print_r ($array2);
$smarty->assign("array2",$array2);
$smarty->display("huoban.tpl");
?>
TPL文件:
<div id="articeBottom">
<{section name=new loop=$array}>
<{$array[new].content}>
<{/section}>
</div><p>
<{section name=n loop=$array2}>
<img alt="" src="../../../fanyi/admin/<{$array2
.logo}>" border="0">
<{/section}>
</p></div>
<?php
include("libs/Smarty.class.php");
$smarty=new Smarty();
$smarty->template_dir="demo/templates";
$smarty->compile_dir="demo/templates_c";
$smarty->left_delimiter="<{";
$smarty->right_delimiter="}>";
$smarty->config_dir="demo/config";
//$smarty->caching=true;//开启缓存
//$smarty->cache_dir="../demo/cache";//缓存文件存放的路径
$array2=array();
mysql_connect("localhost","root","123");
mysql_select_db("fanyi");
mysql_query("set names utf8");
$q="select * from tupian order by id desc limit 1 ";
$result=mysql_query($q);
while($row=mysql_fetch_assoc($result)){
$array2[]=$row;
}
//print_r ($array2);
$smarty->assign("array2",$array2);
$smarty->display("huoban.tpl");
?>
TPL文件:
<div id="articeBottom">
<{section name=new loop=$array}>
<{$array[new].content}>
<{/section}>
</div><p>
<{section name=n loop=$array2}>
<img alt="" src="../../../fanyi/admin/<{$array2
.logo}>" border="0">
<{/section}>
</p></div>
相关文章推荐
- 图片显示在页面,从数据库提取图片并限制图片的大小
- 从数据库提取图片文件显示到前端页面的一种方法
- 用Seam实现:图片上传 + 保存到数据库 + 从数据库读出图片并显示到页面中
- 从数据库读出的JPG文件的字符流,转换成图片显示在页面上的相关代码
- PHP从页面上传图片到数据库(实例)
- 从Oracle中数据库中读取以Blob类型存储的图片显示在jsp页面中
- jsp图片上传到数据库里面之后,不能直接在页面上显示,而是提示下载
- 从数据库中读取图片显示在前台页面
- Asp.net中图片存储数据库以及页面读取显示通用方法详解-附源码下载
- c#存储图片到数据库读数据库显示图片实例
- 从数据库内取图片并在页面上显示
- 也说从数据库里提取图片显示
- 小黑小波比.从数据库读取的图片在页面上显示
- Asp.net中图片存储数据库以及页面读取显示通用方法详解-附源码下载
- struts2中使用Blob类型处理图片上传保存在数据库中并在JSP页面中显示图片
- 从数据库读出的JPG文件的字符流,转换成图片显示在页面上的相关代码
- 从数据库中读取多张图片并显示在同一页面中
- SpringMVC从数据库中读取图片显示到JSP页面上
- 从数据库读出的JPG文件的字符流,转换成图片显示在页面上的相关代码
- web图片上传和数据库取出Blob传到页面显示图片