I have the following problem, I have a customer table that stores the personal data, login, password among others, and another invoice table, which has all the invoices of all the clients, however I need to search the data of the customer with a user ID stored in the invoice table, how do I do this using Code Igniter?
Here is part of the code that searches for invoices:
$query = $this->admin->get_all('faturas')->result();
foreach ($query as $linha) {
echo '<tr>';
printf('<td>%s %s</td>', $linha->nome, $linha->sobrenome);
printf('<td>%s</td>', $linha->numero);
printf('<td>%s</td>', $linha->valor);
printf('<td>%s</td>', ($linha->status==0) ? 'Não':'Sim');
printf('<td class="text-center">%s%s%s</td>',
anchor("admin/cliente/alterar/$linha->id",' ', array('class'=>'table-actions table-edit', 'title'=>'Editar')),
anchor("admin/cliente/alterar_senha/$linha->id",' ', array('class'=>'table-actions table-pass', 'title'=>'Alterar Senha')),
anchor("admin/cliente/excluir/$linha->id",' ', array('class'=>'table-actions table-delete deletareg', 'title'=>'Excluir'))
);
echo '</tr>';
Solved like this:
$query = $this->admin->get_all('faturas')->result();
foreach ($query as $linha) {
$cliente = $this->admin->get_byid('clientes', $linha->id_cliente)->row();
echo '<tr>';
printf('<td>%s %s</td>', $cliente->nome, $cliente->sobrenome);
printf('<td>%s</td>', $linha->numero);
printf('<td>%s</td>', $linha->valor);
printf('<td>%s</td>', ($linha->status==0) ? 'Não':'Sim');
printf('<td class="text-center">%s%s%s</td>',
anchor("admin/cliente/alterar/$linha->id",' ', array('class'=>'table-actions table-edit', 'title'=>'Editar')),
anchor("admin/cliente/alterar_senha/$linha->id",' ', array('class'=>'table-actions table-pass', 'title'=>'Alterar Senha')),
anchor("admin/cliente/excluir/$linha->id",' ', array('class'=>'table-actions table-delete deletareg', 'title'=>'Excluir'))
);
echo '</tr>';
}