You have to put the
table
tag and the table header line before the loop, put the output of the cells into the loop, and let the closing
tbody
and
table
tags after the loop.
I provided a similar answer yesterday at
Database data not display plz solve this[
^]:
<table><thead><tr>
<th>Username</th><th>First Name</th><th>Last Name</th>
</tr></thead><tbody>
<?php foreach ( $datas as $data ):?>
<tr>
<td><?php echo $data->user_name;?></td>
<td><?php echo $data->fname;?></td>
<td><?php echo $data->lname;?></td>
<!--
</tr>
<?php endforeach;?>
</tbody></table>
You have more data columns than header columns. So you should add also the missing header columns (e.g. as empty cells).
I have also not added the cells with the links because I guess that
$data->user_id
does not contain valid links but must be passed as parameters to an existing page.
See also
Views — CodeIgniter 3.1.8 documentation[
^] .