how to print a specific value using while loop in the codeigniter display page?

advertisements

I want to print the value where country name is Canada. using foreach I have got the all value. In the while loop I restrict the value that which I want to print. are there any error in this line==> ins_country = "Canada"): ?>

           <div style="width: 100%">
            <?php foreach ($ins as $i) { ?>
                <?php while ($i->ins_country = "Canada"): ?>
                    <div class="lop_div">
                        <h2> <?php echo $i->ins_country; ?></h2>
                        <?php echo $i->ins_name; ?><br>

                    </div>
                <?php endwhile; ?>
            <?php }
            ?>

        </div>


Instead of while use if condition:

        <?php foreach ($ins as $i) { ?>

            <?php if ($i->ins_country = "Canada"): ?>

                <div class="lop_div">
                    <h2> <?php echo $i->ins_country; ?></h2>
                    <?php echo $i->ins_name; ?><br>

                </div>
            <?php endif; ?>
        <?php }
        ?>