[Smarty] Affectation dans une boucle PHP
Bonjour,
Je voudrais parcourir une boucle, j'utilise smarty
voila ce que j'ai fais mais ca n'a pas l'air de marché
php:
Code:
1 2 3 4 5 6 7 8 9 10 11 12
| $querycat = mysql_query("SELECT cat_id, cat_name FROM categories",$db);
while($data = mysql_fetch_array($querycat)) {
$cid = $data['cat_id'];
$name = $data['cat_name'];
// $smarty->assign('categories', array(
// 'cid' => '$cid',
// 'name' => '$name')
// );
$smarty->assign('cid',"$cid");
$smarty->assign('name',"$name");
//$smarty->display('categories.tpl');
} |
smarty:
Code:
1 2 3 4 5 6 7 8 9 10
| <div id="menu">
<div id="gauche">
<h1>Catégories</h1>
<ul class="menugauche">
{section name=cat loop=$cid}
<li><a href="jeux.php?cid={$cat}&id={$id}">{$name}</a></li>
{/section}
</ul>
</div>
</div> |
merci de m'aidez
PS: je ne savais pas dans quelle partie du forum mettre ce topic, je suis navré:roll: