Quantcast

foreach loop and row color

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

foreach loop and row color

mschwer

Hello!

To retrieve the Output on my views template i used the normal foreach()
loop.

<? foreach ($Programms as $programm): ?>
        <tr>
                <td><? echo $programm['Programm']['wann']; ?></td>
                <td><? echo $programm['Programm']['wo']; ?></td>
                <td><? echo $programm['Programm']['werwas']; ?></td>
                <td><? echo $programm['Programm']['whatelse']; ?></td>
        </tr>
        <? endforeach; ?>

The defined row tag is <tr class='altRow'>. Now I wanna have in the
output that the first row is starting just with <tr> and the second
should be starting with <tr class='altRow'>.

How can i do that?

greetz
Michael


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: foreach loop and row color

Samuel DeVore

>?php foreach ($things as $row=>$thing): ?>
  <tr <?php e(($row%2)?"class='even'":"class='odd'") ?></tr>
     <td><?php e($thing['field']) ?></td>
  </tr>
<?php endforeach; ?>

see if that gives you a hint

On 12/4/06, mschwer <[hidden email]> wrote:

>
> Hello!
>
> To retrieve the Output on my views template i used the normal foreach()
> loop.
>
> <? foreach ($Programms as $programm): ?>
>         <tr>
>                 <td><? echo $programm['Programm']['wann']; ?></td>
>                 <td><? echo $programm['Programm']['wo']; ?></td>
>                 <td><? echo $programm['Programm']['werwas']; ?></td>
>                 <td><? echo $programm['Programm']['whatelse']; ?></td>
>         </tr>
>         <? endforeach; ?>
>
> The defined row tag is <tr class='altRow'>. Now I wanna have in the
> output that the first row is starting just with <tr> and the second
> should be starting with <tr class='altRow'>.
>
> How can i do that?
>
> greetz
> Michael
>
>
> >
>


--
==
S. DeVore
(the old fart) the advice is free, the lack of crankiness will cost you

--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Loading...