jeudi 21 avril 2016

understanding foreach loop[ with if condition

<?php foreach($get_break as $break ) : ?>
                         <?php if($current_time >= $break['break_start'] &&  $current_time <= $break['break_end']) {  ?>
                        <ul class="simple-user-list">
                            <li>
                                <figure class="image rounded">
                                    <img src="assets/images/!sample-user.jpg" alt="Joseph Doe Junior" class="img-circle">
                                </figure>
                                <span class="title">i'm still exists</span>
                                <span class="message truncate">Lorem ipsum dolor sit.</span>
                            </li>
                        </ul>
                        <?php } elseif($break['break_type'] == "Additional break") { ?>
                        <ul class="simple-user-list">
                            <li>
                                <figure class="image rounded">
                                    <img src="assets/images/!sample-user.jpg" alt="Joseph Doe Junior" class="img-circle">
                                </figure>
                                <span class="title">i'm not exists</span>
                                <span class="message truncate">Lorem ipsum dolor sit.</span>
                            </li>
                        </ul>
                        <?php } ?>
                    <?php endforeach ?>

I want to display the break based on the time. i have break master table containing various break type with break start time and break end time. based on the current time, i want to display the break's. Here i;m using foreach for getting data from break table and checking with the condition using if. check break with the current time. for the current time specific break should be displayed. problem is, here if condition is displaying the current, where in the else part , even if the if condition is true it display's the additional break. what shouold i need to do. to display only break, if no current break is exist for the current time. it display the additional break.

Aucun commentaire:

Enregistrer un commentaire