0
Hello, I’m doing the following:
Model:
public function getLocatarios() {
$this->db
->select('*')
->from('tbl_locatario');
return $query = $this->db->get()->result();
}
Already on the controller:
$data = array("tabelaLocatarios" => $this->Locatario_Model->getLocatarios());
$this->load->view('teste', $data);
Already in HTML
<table width="100%" class="table table-striped table-bordered table-hover" id="dataTables-example">
<thead>
<tr>
<th>Nome</th>
<th>E-mail</th>
<th>Telefone</th>
<th>Opções</th>
</tr>
</thead>
<tbody>
<?php if (!empty($tabelaLocatarios)):
foreach ($tabelaLocatarios as $row): ?>
<td>
<?php echo $row->NOME;?>
</td>
<td>
<?php echo $row->EMAIL;?>
</td>
<td>
<?php echo $row->TELEFONE1;?>
</td>
<td>
Opções arrumar
</td>
<?php endforeach; ?>
<?php else: {
echo "<td colspan='5' align = 'center'>
Você ainda não possui nenhum locatário cadastrado...
</td>";
} ?>
<?php endif; ?>
</tbody>
</table>
However this returning me in just one row, I would like it to return in one table with one row below the other.
What am I doing wrong?
each row of a table is one
<tr></tr>
lacked it in your code– novic