Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Por exemplo, estou mandando um array de id [0] => 1, [1] => 3 e quero mostrar isso no meu html em forma de resultado. No caso, que buscar no banco o com o primeiro id salvar no array e depois buscar com o segundo id e por fim retornar um array contendo os outros dois 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();
}ygor, deu certo, porém está repetindo o índice do array.
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] =>
)
) [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] =>
)
)
public function getRecibos($codigosRecibo)
{
$result[] = '';
foreach ($codigosRecibo as $codigoRecibo)
{
$this->db->select('*');
$this->db->where('idRecibo', $codigoRecibo);
$this->db->from('recibo');
$result[] = $this->db->get()->result_array(); //Ja tentei com result, resul_array, row, row_array
}
return $result;
}
E sempre está dando este erro:
**A PHP Error was encountered**
**Severity: Notice**
**Message: Trying to get property of non-object**
**Filename: financeiro/imprimirVarios.php**
**Line Number: 28**
**Backtrace:**
**File: /home/u996471193/domains/sansiqdev.com.br/public_html/cloud/neri/application/views/financeiro/imprimirVarios.php
Line: 28
Function: _error_handler**
**File: /home/u996471193/domains/sansiqdev.com.br/public_html/cloud/neri/application/controllers/Financeiro.php
Line: 313
Function: view**
**File: /home/u996471193/domains/sansiqdev.com.br/public_html/cloud/neri/index.php
Line: 319
Function: require_once**
View:
<?php foreach ($recibos as $recibo) {?>
<div class="container" style="margin-top: 0;">
<div class="col-12">
<table style=" width: 100%;">
<tr>
<td>
<img src="<?=$emitente->emitente_Logo?>" width="104">
</td>
<td>
<h5><?=$emitente->emitente_Nome?> - <?=$emitente->emitente_Funcao?></h5>
<span style="font-size: 12px"><?=$emitente->emitente_Cremers?> - INSS <?=$emitente->emitente_Inss?></span><br>
<span style="font-size: 12px"><?=$emitente->emitente_Endereco?>, <?=$emitente->emitente_Numero?> - <?=$emitente->emitente_Cidade?>/<?=$emitente->emitente_Estado?></span>
<span style="font-size: 12px">Telefone: <?=$emitente->emitente_Telefone?></span>
</td>
</tr>
</table>
<div class="row">
<div class="col-12 text-center">
<h5 style="font-weight: bold;">Recibo</h5>
<span style="font-size: 13px">Recebi de <strong style="font-weight: bold;"><?=$recibo->recibo_Recebi?></strong>, a impotância de <strong style="font-weight: bold;">R$ <?=$recibo->recibo_Valor?></strong>, relativo ao atendimento de <strong style="font-weight: bold;"><?=$recibo->recibo_Relativo?></strong></span>
</div>
</div>
<div class="row mt-4 align-items-center">
<div class="col-12 text-center" style="font-size: 12px">
<span>Pelotas, <strong style="font-weight: bold;"><?=$recibo->recibo_Dia?></strong> de <strong style="font-weight: bold;"><?=$recibo->recibo_Mes?></strong> de <strong><?=$recibo->recibo_Ano?></strong></span>
<br>
<br>
<span>________________________________________________________________________________________________________</span><br>
<span class="mt-0"><?=$emitente->emitente_Nome?></span>
</div>
<br>
</div>
</div>
</div>
<hr size="1" style="border:1px dashed #ccc;">
<?php } ?>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()->result();
}
return $result;
}
public function getRecibos($codigosRecibo)
{