0
我稱之爲PHP文件testfun.php
獲取數據庫值
<?php
$conn=mysql_connect("localhost","root","") or die("unabke to connect");
$db=mysql_select_db("smartyform",$conn) or die("databse error");
require 'Smarty/libs/Smarty.class.php';
$smarty = new Smarty;
$sel=mysql_query("select * from form");
while($row=mysql_fetch_array($sel))
{
$id=$row[0];
$name=$row[1];
}
$smarty->assign('id',$id);
$smarty->assign('name',$name);
$smarty->display('testfunction.tpl');
?>
我已經TPL文件名爲testfunction.tpl
<body>
<ul>
{$id}
:
{$name}
</ul>
</body>
</html>
當我運行testfun.php
我得到這樣的輸出:
16 : dg
但我想輸出像:
1:d
d:g
我該怎麼辦?
可能重複( http://stackoverflow.com/questions/11920553/getting-value-in-smarty-template) – rodneyrehm 2012-08-12 07:58:11