我表里 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
------------------------------------
-----------------------------
[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
------------------------------------
$array[] = $row;
}
$template= new SmartTemplate('user.html');
$template->assign('product_avgtable',$array);
$template->output();