Comparison of Cities between Excerpts

2

Hello! I am developing a system that consists of registering parts by neighborhood or city. In this case that I am taking as an example, it includes only two excerpts, as I show in the figure. My question is, how to buy the snippets that are coming from the array (), I know that in the first stretch the cities are the same, but how to buy the second snippet, and can there be more snippets?

The code I developed is as follows:

$intContagem = 1;
$intContagemArray = count($dados)-1;

for($idDados = 1; $idDados<=$intContagemArray; $idDados++){
    $idDadosAnt = 0;

    if($dados[0]['cidade'] == $dados[1]['cidade']){
        $sql = "SELECT $strSelect as vlrFrete FROM tabelafrete WHERE idSaida = ".$dados[$idDadosAnt]['bairro']." AND idDestino = ".$dados[$idDados]['bairro']."";   
    } else {
        $sql = "SELECT $strSelect as vlrFrete FROM tabelafretem WHERE idSaida = ".$dados[$idDadosAnt]['cidade']." AND idDestino = ".$dados[$idDados]['cidade']." AND referencia = 'C'";
    }

    $consulta = $this->db->query($sql)->result();
        foreach($consulta as $valor){
            $intContagem += $valor->vlrFrete;
        }
}

Comparative section:

    
asked by anonymous 02.09.2015 / 13:36

0 answers