|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
kiruban Smarty Rookie
Joined: 06 Aug 2006 Posts: 8
|
Posted: Sun Aug 06, 2006 3:17 pm Post subject: php, smarty et boucle |
|
|
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: | $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: | <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
|
|
Back to top |
|
ciboulette Smarty Regular
Joined: 13 Jul 2006 Posts: 45
|
Posted: Sun Aug 06, 2006 11:31 pm Post subject: |
|
|
php :
[php:1:69e88d3670]
$cid = array();
$querycat = mysql_query("SELECT cat_id, cat_name FROM categories",$db);
while($data = mysql_fetch_assoc($querycat)){
array_push ($cid, $data);
}
$smarty->assign('cid',$cid);
$smarty->display('categories.tpl');
[/php:1:69e88d3670]
Smarty :
Code: |
<div id="menu">
<div id="gauche">
<h1>Catégories</h1>
<ul class="menugauche">
{section name=cat loop=$cid}
<li><a href="jeux.php?cid={$cid[cat].cat_id">{$cid[cat].cat_name}</a></li>
{/section}
</ul>
</div>
</div>
|
Essaye ça , c peuetre se que tu veux faire.
Last edited by ciboulette on Mon Aug 07, 2006 2:14 pm; edited 1 time in total |
|
Back to top |
|
kiruban Smarty Rookie
Joined: 06 Aug 2006 Posts: 8
|
Posted: Mon Aug 07, 2006 8:25 am Post subject: |
|
|
Warning: array_push(): First argument should be an array in c:\program files\easyphp1-8\www\allogift\avant.php on line 63
Warning: array_push(): First argument should be an array in c:\program files\easyphp1-8\www\allogift\avant.php on line 63
Warning: array_push(): First argument should be an array in c:\program files\easyphp1-8\www\allogift\avant.php on line 63
Warning: array_push(): First argument should be an array in c:\program files\easyphp1-8\www\allogift\avant.php on line 63
Warning: array_push(): First argument should be an array in c:\program files\easyphp1-8\www\allogift\avant.php on line 63
tu peux m'aider stp |
|
Back to top |
|
kiruban Smarty Rookie
Joined: 06 Aug 2006 Posts: 8
|
Posted: Mon Aug 07, 2006 8:41 am Post subject: |
|
|
Code: | Warning: array_push(): First argument should be an array in c:\program files\easyphp1-8\www\allogift\avant.php on line 63
Array ( [0] => 1 [1] => Argent/grattage )
Warning: array_push(): First argument should be an array in c:\program files\easyphp1-8\www\allogift\avant.php on line 63
Array ( [0] => 2 [1] => Jeux-vidéo )
Warning: array_push(): First argument should be an array in c:\program files\easyphp1-8\www\allogift\avant.php on line 63
Array ( [0] => 3 [1] => High-Tech )
Warning: array_push(): First argument should be an array in c:\program files\easyphp1-8\www\allogift\avant.php on line 63
Array ( [0] => 4 [1] => Téléphone/GSM )
Warning: array_push(): First argument should be an array in c:\program files\easyphp1-8\www\allogift\avant.php on line 63
Array ( [0] => 5 [1] => Informatique ) |
voila ce que j'ai avec print_r($data); |
|
Back to top |
|
ciboulette Smarty Regular
Joined: 13 Jul 2006 Posts: 45
|
Posted: Mon Aug 07, 2006 2:15 pm Post subject: |
|
|
voila j'ai re edité mon code essaye voir
sinon tien : alx92z@hotmail.com , voila mon MSN |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|