Home  >  Article  >  Backend Development  >  为啥smarty循环fetch的话,每次内容都一样

为啥smarty循环fetch的话,每次内容都一样

WBOY
WBOYOriginal
2016-06-13 11:04:081051browse

为什么smarty循环fetch的话,每次内容都一样
各位大哥,小弟初学php和smatry,请指教。
为什么文件都生成了,就是里面的内容都一样的。
我又打印了下,但是打印出来的都是正确的。

<br />foreach ( $category as $c ) {<br />	$products = $util->getArrayByQueryString ( "select * from product_detail where sid=$c[id]" );<br />	$smarty->assign ( "html_title", $c [name] . ':所有子类产品' );<br />	$smarty->assign ( "products", $products );<br />//	foreach ( $products as $p ) {<br />//		echo $p [id] . $p [name] . '<br/>';<br />//	}<br />	$content = $smarty->fetch ( "products.tpl" );<br />	$file_name = './products/' . $c [id] . '.html';<br />	//html生成<br />	create_html ( $file_name, $content );<br />}<br />

------解决方案--------------------
$content = $smarty->fetch ( "products.tpl",ID之类的参数 );

这样试试

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn