SmartTemplate模板读取数据不能循环

abc_2004 2011-08-29 11:59:16
我表里 product_avgtable 有5条数据
-----------------------------
[pid][news_id][news_date][news_price][news_proportion]
14 72 2011-08-22 06:02:58 7.00 0.179
13 72 2011-08-22 06:02:03 5.75 0.130
12 72 2011-08-22 06:01:25 5.00 0.999
15 72 2011-08-22 06:13:19 6.50 -0.077
-----------------------------------
PHP

<?php
include_once("../Mconfig/conndb.inc.php");//连接MYSQL
include_once("../Mconfig/templateConfig.inc.php");//连接SmartTemplate
$rs=mysql_query("select pid,news_id,news_date,news_price,news_proportion from product_avgtable order by pid DESC");
?>
while($array=mysql_fetch_array($rs)){<?
$array=array(
array('pid'=>$array["pid"],),
array('news_id'=>$array["news_id"],),
array('news_price'=>$array["news_price"],),
array('news_date'=>$array["news_date"],),
);
$template= new SmartTemplate('user.html');
$template->assign('product_avgtable',$array);
$template->output();
}
?>

user.html模板

<table width="75%" border="1">
<tr>
<!-- BEGIN product_avgtable -->
</tr>
<tr>
<td>{pid}</td>
<td>{news_id}</td>
<td>{news_price}</td>
<td>{news_date}</td>
</tr>
<tr>
<!-- END product_avgtable -->
</tr>
</table>

输出-----(问题是不能循环显示表内的数据)
-----------------------------------
15 72 6.5 2011-08-22 06:13:19
15 72 6.5 2011-08-22 06:13:19
15 72 6.5 2011-08-22 06:13:19
15 72 6.5 2011-08-22 06:13:19
------------------------------------



...全文
117 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
tkfn123 2011-08-29
  • 打赏
  • 举报
回复
我是来学习的~ 哈哈
ewing333 2011-08-29
  • 打赏
  • 举报
回复
mark,学习。
xuzuning 2011-08-29
  • 打赏
  • 举报
回复
while($row=mysql_fetch_assoc($rs)){
$array[] = $row;
}
$template= new SmartTemplate('user.html');
$template->assign('product_avgtable',$array);
$template->output();

20,359

社区成员

发帖
与我相关
我的任务
社区描述
“超文本预处理器”,是在服务器端执行的脚本语言,尤其适用于Web开发并可嵌入HTML中。PHP语法利用了C、Java和Perl,该语言的主要目标是允许web开发人员快速编写动态网页。
phpphpstorm 技术论坛(原bbs)
社区管理员
  • 开源资源社区
  • phpstory
  • xuzuning
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧