【发布时间】:2014-08-26 12:13:44
【问题描述】:
我是 smarty 的新手,我有一个小问题,我无法为我的帖子获取图像。我将图像路径存储在表 ( images ) 中,将帖子存储在表 (posts) 中:
我的php代码是
$get_new_jobs=$mysqli->query("select id,numview,title,cat1,details,country,active from ads where country='".$country_en."' and active='1' order by id desc limit 4");
$nums=$get_new_jobs->num_rows;
while($row=$get_new_jobs->fetch_assoc()){
$mm[]=$row;
}
$smarty->assign('posts',$mm);
$smarty->assign('image',$the_images_name);
$smarty->display('posts.tpl');
我的图片代码是
$sql=mysqli->query("select adid,image,p from images where adid='".$row['id']."'");
$fet = $sql->fetch_assoc();
$the_images_name = $fet['image'];
tpl 代码是
<table width="100%" border="0" cellpadding="5">
{foreach from=$posts item=item}
<tr valign="top">
<td>
{$image}
<br />
{$item.title}
</td>
</tr>
{/foreach}
</table>
那么我怎样才能为每个帖子获取每张图片。
问候
【问题讨论】:
-
第一件事 {$image} 应该像 第二你每个帖子有多个图片吗?
-
我怎样才能在帖子循环中插入图片查询亲爱的......这就是我需要的