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(寻梦的稻草人)在网上也看到了关于你的许多事 你的冰山文章发布系统很不错啊啊能得到你的回答 我很高兴但是你的 答案我不知道怎么用 请说明一下好吗? PHP 二维数组的读出 smarty foreach ini_set("include_path",ini_get("include_path").": /path/to/pear"); 简单问题,php中是否可以使用自定义的c语言的库文件。例如dll,so等 散点分,谈谈最近学习心得体会 问个sql问题 在php中如何使文本框只输入数字? 用PHP怎么实现分页,我的数据库是MSSQL7 用了PDO连接数据库之后,出现了一个问题 关于图片引用URLREWRITE的问题。 纯散分--感觉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;
}
能得到你的回答 我很高兴但是你的 答案我不知道怎么用 请说明一下好吗?