mousa777:

I'm assuming that the missing end tags John refers to is in the "//
all the thing that to be displayed here //" comment, as well as the
tag(s) that actually use the $class variable.

Look at the part of your code:
        if ($i++ % 2 == 0) {
                $class = ' class="altrow"';
        }

What this does:
* get the current row number ( $i++ ),
* divide it by 2 and get the remainder ( % 2 );
  * if there is no remainder ( = 0 ), assign ' class="altrow"' to the
variable $class
  * otherwise leave the variable $class null

This essentially makes every even row use the altrow class (usually
shaded), and every odd row default.  If you want it to be: first two
rows default, next two rows shaded, repeat; you will need to change
the if condition.  Hint: instead of repeating the pattern every two
lines, you're repeating every 4 lines.

Alternatively, you can use the CSS pseudoclass "nth-child".  You will
have to do this if none of your tags in the "// all the thing that to
be displayed here //" actually use the $class variable.  There are
tons of information regarding use of "nth-child" accessible through
Google Search.

On Feb 9, 2:20 am, mousa777 <[email protected]> wrote:
> i have a problem with displaying tq records in each row of a list
> my code look like this
>
> <ol class="list">
> <?php
> $i = 0;
> foreach ($works as $work):
>         $class = null;
>         if ($i++ % 2 == 0) {
>                 $class = ' class="altrow"';
>         }
> ?>
>         <li class="clearfix">
>                 <div class="side-info">
>                  // all the thing that to be displyed here //
> <?php endforeach;?>
> </ol>
>
> the results i am getting are displayed one in each row
> but i want to display two results in each row
>
> any help please
> thankx in advance

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to