2
For example, I am sending an id array [0] => 1, [1] => 3 and I want to show this in my html as a result. In the case that you search in the database with the first id save in the array and then search with the second id and finally return an array containing the other two arrays.
public function getRecibos($codigosRecibo)
{
$result = array('');
foreach ($codigosRecibo as $codigoRecibo)
{
$this->db->select('*');
$this->db->where('idRecibo', $codigoRecibo);
$this->db->from('recibo');
$result = $this->db->get();
}
return $result->result();
}
I did so but it is always making the indexes of the array to be 0
public function getRecibos($codigosRecibo)
{
$result = array('');
foreach ($codigosRecibo as $codigoRecibo)
{
$this->db->select('*');
$this->db->where('idRecibo', $codigoRecibo);
$this->db->from('recibo');
$result[] = $this->db->get();
}
return $result->result();
}
Array
(
[0] => Array
(
[idRecibo] => 2
[recibo_Recebi] => Condomínio Edifício Dona Gladis
[recibo_Relativo] => 02 consultas periódicas - Catia da Silva, Gabriel Vinholes
[recibo_Valor] => 64,00 (sessenta e quatro reais)
[recibo_Dia] => 01
[recibo_Mes] => Março
[recibo_Ano] => 2019
[recibo_Data] => 2019-03-01
[recibo_Forma_pgto] => 0
[recibo_idCheque] => 0
[recibo_Pago] => s
[recibo_DataPgto] => 2019-03-13
[idCheque] =>
[cheque_Emitente] =>
[cheque_Numero] =>
[cheque_Banco] =>
[cheque_Cic_Cnpj] =>
)
)
Array
(
[0] => Array
(
[idRecibo] => 1
[recibo_Recebi] => Condomínio Edifício Porto Vecchio
[recibo_Relativo] => 01 consulta periódica - Ronaldo Faria
[recibo_Valor] => 32,00 (trinta e dois reais)
[recibo_Dia] => 01
[recibo_Mes] => Março
[recibo_Ano] => 2019
[recibo_Data] => 2019-03-01
[recibo_Forma_pgto] => 0
[recibo_idCheque] => 0
[recibo_Pago] => s
[recibo_DataPgto] => 2019-03-13
[idCheque] =>
[cheque_Emitente] =>
[cheque_Numero] =>
[cheque_Banco] =>
[cheque_Cic_Cnpj] =>
)
)
Thanks beast. It worked perfectly. <3
– José Luis
If you can help me one more time, there’s another post of mine that I’m struggling with. https://answall.com/questions/367425/dois-foreach-em-um-select
– José Luis