Where's my mistake?

3 posts by 2 authors in: Forums > CMS Builder
Last Post: May 6, 2013   (RSS)

By Jason - May 6, 2013

Hi Tim,

The issue is this if block here:

<?php if (@$lastDate == $date): ?>
            </tbody>
        </table>
    </div>
<?php endif ?>

What this is trying to do is that every time the last date is the same as the current date, close out the table.  But the table doesn't get re-opened unless the dates are different.  To fix this, remove this block from the bottom of the foreach loop and change the block at the top like this:

    <?php if (@$lastDate != $date): ?>
    
    <?php if (@$lastDate): ?>
            </tbody>
        </table>
    </div>
  <?php endif ?>
    
    <div class="calendar">
    <h2><?php echo $date ?></h2>
        <table>
            <thead>
                <tr>
                    <th>Date</th>
                    <th>Event</th>
                    <th>Contact</th>
                    <th>Entry</th>
                </tr>
            </thead>
            <tbody>
    
    <?php endif ?>

This should close the last table before it reopens the next.  This won't execute during the first iteration of the loop as $lastDate won't have a value.

Hope this helps

---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By Toledoh - May 6, 2013

So clear after you point it out.  Thanks Jason!

Cheers,

Tim (toledoh.com.au)