Home » Php » php – BOOTSTRAP Looping checkbox

php – BOOTSTRAP Looping checkbox

Posted by: admin February 25, 2020 Leave a comment

Questions:

I have a problem with looping checkbox bootstrap from result_array()
this the pics 1
and this the code

<?php if ($bn) : ?>
<div class="row">
    <?php foreach ($bn as $a) : ?>
    <div class="col">
        <div class="form-check">
            <input class="form-check-input" type="checkbox" value="1" id="1" name="1" checked>
            <label class="form-check-label" for="1">Data</label>
        </div>
    </div>
    <?php endforeach; ?>
</div>
<?php endif; ?>

my data in database 5 record

how to get data like that result_array()
be like 2

I mean if looping has been done 4 times. make a new row. so each row is filled with 4 columns

How to&Answers:

Do you mean that you want the 5th checkbox to be at the bottom? if so why not replace:

    <div class="col">

with

<div class="col-3 mb-3">

?

Answer:

The bootstrap grid system is divided in 12 col space total.

You can change the class of the div to <div class="col-3"> which will put 4 cols(4*3 = 12) in the first row and the 5th col in a second row.