Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

for($i=1;$i<=$count;$i++)

 
Post new topic   Reply to topic    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
ferre
Smarty Rookie


Joined: 07 Jul 2003
Posts: 28

PostPosted: Mon Oct 06, 2003 4:07 am    Post subject: for($i=1;$i<=$count;$i++) Reply with quote

in php
for($i=1;$i<=$count;$i++)
{
xxxxxxx
}

but in smarty, i assign("COUNT",$count);
what should i do , plz help
Back to top
View user's profile Send private message
mikeken
Smarty Regular


Joined: 13 Aug 2003
Posts: 57
Location: MN

PostPosted: Mon Oct 06, 2003 8:13 pm    Post subject: Reply with quote

What is your question?
I see you want to do something...but what?
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Mon Oct 06, 2003 9:31 pm    Post subject: Reply with quote

my crystal-sphere may lie, but i think you want:

{section name=i loop=$count}
i is: {$smarty.section.i.iteration}
{/section}
Back to top
View user's profile Send private message Send e-mail Visit poster's website
idxman01
Smarty Rookie


Joined: 10 Jun 2003
Posts: 14
Location: FL

PostPosted: Wed Dec 03, 2003 8:33 pm    Post subject: Reply with quote

Thanks for the info messju, that's what I was just looking for.

Although I'm running into a problem during the loop. Basically I have a variable number of loops per row, where the variable name contains the loop number.

eg:

$results is an array of objects that I'm already looping through.
$results[row]->r_nbr_tpl is an integer from 0-5

So then I need to iterate that many times and print out vars like:

r_tpl_cc_1 , r_tpl_cc_2

Code:

{section name=row loop=$results}
//print stuff

  {section name=i loop=$results[row]->r_nbr_tpl}
  // ok, so this is where I'd need to print $results[row]->r_tpl_cc_1, 2, 3, etc. depending on what loop section i was on.
  I've tried: {$results[row]->r_tpl_cc_$smarty.section.i.iteration} , but I get parse errors in the compiled template.
  {/section}
{/section}


any ideas?


Thanks,

-r
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Wed Dec 03, 2003 10:32 pm    Post subject: Reply with quote

use arrays instead of variable variables. i think that's the best one in the long run.

greetings
messju
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> General 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