como usar while com smarty????
olá, gostaria de saber como posso exibir postes com while no smarty???
no arquivo tpl eu usei o foreach só que não mostra nada olha como coloquei:
index.php
<?php$root_path = "./";include ($root_path."common.php");//título da página$page_title = "Página Inicial";include ($roor_path."includes/page_header.php");$sql = mysql_query('SELECT id, title, content FROM posts ORDER BY id DESC');while($array = mysql_fetch_array($sql)){ $smarty->assign('posts', array('title' => $array['title'], 'content' => $array['content']));}//exibe há página$smarty->display("index.tpl");include ($roor_path."includes/page_footer.php");?>
index.tpl
{foreach key=id item=con from=$posts} <h1>{$con.title}</h1> <p>{$con.content}</p> {/foreach}
só que só exibe as letras inicial e apenas um insert???
se alguem poder ajudar fico grato.
obrigado
Discussão (1)
Carregando comentários...