No no.

I did figure it out on my own.

But I was pulling records fron the db with unknown number so each row would
be

Record1 | Record2| Record3

Record4 | Record5| Record6

Record7 | Record8| RecordX....
And so on

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf
Of mike karthauser
Sent: February-08-10 6:12 AM
To: [email protected]
Subject: Re: Help with foreach

if you know you've only got 3 or less skills why not just declare the
variables by name or position?


<fieldset>
<div class="single">

          <?php foreach ($skills as $skill): ?>

<div class="trio">

                   <?php 
                        // 1, 2, 3

if(isset($skill[0]))
echo $skill[0];

if(isset($skill[1]))
echo $skill[1];


if(isset($skill[2]))
echo $skill[2];


?>
    </div>
     <?php endforeach; ?>

   </div>

</fieldset>


seems far simpler to me.



On 8 Feb 2010, at 07:05, Dave wrote:


        I am looping thru an array putting 3 of the values in a row using my
<div>
        but my problem is if the last row has only 1 or 2 values its not
closing
        properly.
        
        <?php
        $i = 0;
          $rowmax = 3;
          $rowcount = 0; ?>
        
        <fieldset>
        <div class="single">
        
                  <?php foreach ($skills as $skill): ?>
        
        <div class="trio">
        
                           <?php 
                                // 1, 2, 3
        
                           $i++;
                           $rowcount++;
        
                           if ($rowcount == $rowmax):?>
        
            </div>
           </div>
        
        </fieldset>
        
        <fieldset>
        <div class="single">
        
        
           <?php $rowcount = 0;?>
        
          <?php else :?>
          </div>
         <?php endif ?>
        
             <?php endforeach; ?>
        
        
        Here if the last row only has 1 or 2 the <div class="single"> and
<fieldset>
        are not closed off sinces it waiting for the 3rd to close out the
group.
        
        Any ideas here?
        
        Thanks
        
        Dave
        
        Check out the new CakePHP Questions site http://cakeqs.org and help
others with their CakePHP related questions.
        
        You received this message because you are subscribed to the Google
Groups "CakePHP" group.
        To post to this group, send email to [email protected]
        To unsubscribe from this group, send email to
        [email protected] For more options, visit this
group at http://groups.google.com/group/cake-php?hl=en
        
        


--
Mike Karthäuser
Managing Director - Brightstorm Ltd
Email: [email protected]
Web: http://www.brightstorm.co.uk <http://www.brightstorm.co.uk/>
Tel: 07939 252144
Address: 1 Brewery Court, North Street, Bristol, BS3 1JS

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + +

On 7th March 2010, I am running the Bath Half Marathon to raise sponsorship
for the Royal National Lifeboat Institution. 

Visit http://www.justgiving.com/mike-karthauser and help me raise £500 to
support UK Lifeguards. 

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + +


Check out the new CakePHP Questions site http://cakeqs.org and help others
with their CakePHP related questions.
 
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected] To
unsubscribe from this group, send email to
[email protected] For more options, visit this group 
cake-php+at http://groups.google.com/group/cake-php?hl=en


Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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

Reply via email to