Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

php, smarty et boucle

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: French
View previous topic :: View next topic  
Author Message
kiruban
Smarty Rookie


Joined: 06 Aug 2006
Posts: 8

PostPosted: Sun Aug 06, 2006 3:17 pm    Post subject: php, smarty et boucle Reply with quote

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

Rolling Eyes Rolling Eyes
Back to top
View user's profile Send private message
ciboulette
Smarty Regular


Joined: 13 Jul 2006
Posts: 45

PostPosted: Sun Aug 06, 2006 11:31 pm    Post subject: Reply with quote

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
View user's profile Send private message
kiruban
Smarty Rookie


Joined: 06 Aug 2006
Posts: 8

PostPosted: Mon Aug 07, 2006 8:25 am    Post subject: Reply with quote

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
View user's profile Send private message
kiruban
Smarty Rookie


Joined: 06 Aug 2006
Posts: 8

PostPosted: Mon Aug 07, 2006 8:41 am    Post subject: Reply with quote

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
View user's profile Send private message
ciboulette
Smarty Regular


Joined: 13 Jul 2006
Posts: 45

PostPosted: Mon Aug 07, 2006 2:15 pm    Post subject: Reply with quote

voila j'ai re edité mon code essaye voir
sinon tien : alx92z@hotmail.com , voila mon MSN
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: French All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP