SmartTemplate 循环3行2列 从数据库 读取数据 对了 是在 php 中 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你到底是想在smarty里用section循环还是想在php里循环?section换行可以通过类似: <tr><{section name="info" loop=$infoarr show = true}><{if $smarty.section.info.index%2==0}></tr><tr><{/if}><td></td><{/section}><tr>来控制,php里的for,while,foreach都可以的.. 增加一个判定语句比如你使用的循环中,使用了$i做的标记,那么,使用以下语句if (($i+1)/2==0) echo "</tr><tr>";成了吧?? li1229363你说的 是可以 可是包含的 哪个页面时 html de 怎么能 用echo 呢? ai_ni谢谢你我是要在包含的html 静态页面里面 用smatttemplate循环 在程序页//$list 是列表的数组 以下是一行三组图片的$i = 0;foreach ($list as $key=>$val)//无缩略图,用原图{ $list[$key]["full_thumbnail_url"] = (empty($val['full_thumbnail_url']))?$val['full_item_url']:$val['full_thumbnail_url']; $list[$key]["_next_line"] = (($key+1)%3) ? 0:1;}模板页 //<table border="0" cellspacing="0" cellpadding="0"> <tr> <!-- BEGIN list --> <td> {img} </td> <!-- IF _next_line --> </tr> <tr> <!-- ENDIF --> <!-- END list --> </tr> </table> $list[$key]["full_thumbnail_url"] = (empty($val['full_thumbnail_url']))?$val['full_item_url']:$val['full_thumbnail_url'];程序页这行不要,哈哈,手快程序COPY过来,没有删掉! /** * 功能 将数据转换为SmartTemplate表格格式 * * @param array $records 数组记录 * @param int $cols 表格中每行显示的记录数 * @param string $colsKey 数组中每行的键名 */ public function tableFormat($records, $cols=5, $colsKey="TD") { $ROWS = array(); while($col = array_splice($records, 0, $cols)) { $ROWS[][$colsKey] = $col; } return $ROWS; } 谢谢你ice_berg16(寻梦的稻草人)在网上也看到了关于你的许多事 你的冰山文章发布系统很不错啊啊能得到你的回答 我很高兴但是你的 答案我不知道怎么用 请说明一下好吗? index.php访问时是空白 PHP代碼問題 如何实现新闻内容关键词自动添加链接功能?希望高手解答! php函数优先级问题 高手请进,在register_globals off后,无法传递类变量 mod_sql是什么东东啊,送分了 怎么才能使用户每次看到新页面而不用刷新才能看到?? PHP怎么定义全局变量?是不是Apache下的程序在IIS下要改变才能用? PHP如何执行外部命令,如adduser! preg_replace改写preg_replace_callback的问题 纯散分--感觉PHP版块人气越来越不好了 帮我看看这个中文截取字符串的函数正不正确
section换行可以通过类似:
<tr>
<{section name="info" loop=$infoarr show = true}>
<{if $smarty.section.info.index%2==0}>
</tr>
<tr>
<{/if}>
<td></td>
<{/section}>
<tr>
来控制,php里的for,while,foreach都可以的..
你说的 是可以
可是包含的 哪个页面时 html de
怎么能 用echo 呢?
谢谢你
我是要在
包含的html 静态页面里面 用smatttemplate循环
//$list 是列表的数组 以下是一行三组图片的
$i = 0;
foreach ($list as $key=>$val)//无缩略图,用原图
{
$list[$key]["full_thumbnail_url"] = (empty($val['full_thumbnail_url']))?$val['full_item_url']:$val['full_thumbnail_url']; $list[$key]["_next_line"] = (($key+1)%3) ? 0:1;
}模板页 //
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<!-- BEGIN list -->
<td>
{img}
</td>
<!-- IF _next_line -->
</tr>
<tr>
<!-- ENDIF -->
<!-- END list -->
</tr>
</table>
程序页这行不要,哈哈,手快程序COPY过来,没有删掉!
* 功能 将数据转换为SmartTemplate表格格式
*
* @param array $records 数组记录
* @param int $cols 表格中每行显示的记录数
* @param string $colsKey 数组中每行的键名
*/
public function tableFormat($records, $cols=5, $colsKey="TD")
{
$ROWS = array();
while($col = array_splice($records, 0, $cols))
{
$ROWS[][$colsKey] = $col;
}
return $ROWS;
}
能得到你的回答 我很高兴但是你的 答案我不知道怎么用 请说明一下好吗?