[Solved] How to fetch data using foreach in one form codeigniter [closed]


First of all check your query using echo $this->db->last_query(); put this code in controller where you write $data['invoices'] and then check its working or not then use below code in your view part.

<div class="form-group">
    <label for="int">Clients Id <?php echo form_error('clients_id') ?></label>
    <select class="form-control select2 select2-hidden-accessible" style="width: 100%;">   
        <center><option selected="selected">--- Select ---</option></center>
        <?php
            foreach ($invoices as $row) 
            {

                echo '<option class="form-control select2" value="'.$row['client_id'].'">'.$row['first_name'].'</option>';
            }
        ?>
    </select>
</div>
<div class="form-group">
    <label for="int">Suppliers Id <?php echo form_error('suppliers_id') ?></label>
    <select class="form-control select2 select2-hidden-accessible" se="width: 100%;">   
        <center><option selected="selected">--- Select ---</option></center>
        <?php
            foreach ($invoices as $row) 
            {

                echo '<option class="form-control select2"  value="'.$row['service_id'].'">'.$row['service_name'].'</option>'
            }
        ?>
    </select>
</div>

8

solved How to fetch data using foreach in one form codeigniter [closed]