Welcome Guest, Not a member yet? Register   Sign In
I can not pass array loop for view
#2

You have loop inside a loop. $consulta will ever have the last value of the last query.
PHP Code:
foreach ($complementar->result() as $key => $value) {
    for (
$i=0$i $key $i++) { 
        
$consulta $this->db->query(...)->result();
    }


As simple fix you can keep most of the code logic, but add results to existing persistent array:
PHP Code:
$consulta = [];
foreach (
$vetor as $xvet => $valuevetor) {
    
// ...
    
foreach ($complementar->result() as $key => $value) {
        for (
$i=0$i $key $i++) { 
            
$consulta array_merge($consulta$this->db->query(...)->result());
        }
    }


I would suggest finding a way to get all the data back in a single query tho, if possible, putting queries in couple of nesting loops is very time-consuming.
Reply


Messages In This Thread
I can not pass array loop for view - by n0cturn0 - 11-08-2018, 04:00 AM
RE: I can not pass array loop for view - by Pertti - 11-08-2018, 05:55 AM



Theme © iAndrew 2016 - Forum software by © MyBB