<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?>

<div class="table-responsive">
  <table class="table table-sm table-bordered table-striped table-hover">
    <thead>
      <tr>
        <th style="text-align: center; width: 50px">No</th>
        <?php  for ($i=0; $i < count($data['column_name']); $i++){ ?>
          <th style="text-align: center;"><?php echo $data['column_name'][$i] ?></th>
        <?php } ?>
      </tr>
    </thead>
    <tbody>
      <?php if(!empty($data['result'])){ for ($i=0; $i < count($data['result']); $i++) { ?>
        <tr>
          <td style="text-align: center;"><?php echo $i+1 ?></td>
          <?php  for ($j=0; $j < count($data['column_name']); $j++){ $column_name = $data['column_name'][$j] ?>
            <td style="text-align: center;"><?php echo $data['result'][$i]->$column_name ?></td>
          <?php } ?>
        </tr> 
      <?php } } ?>
    </tbody>
  </table>
</div>