<?php
//database configuration
$dbHost = '127.0.0.1';
$dbUsername = 'root';
$dbPassword = '';
$dbName = 'master';
//connect with the database
$Mysqli = new mysqli($dbHost,$dbUsername,$dbPassword,$dbName);
$arr = array();
//get matched data from skills table
if(empty($erro)){
$query = "SELECT
r.endereco_cep AS CEP,
r.endereco_logradouro AS ENDERECO,
b.bairro_descricao AS BAIRRO,
c.cidade_codigo AS CODCID,
c.cidade_descricao AS CIDADE,
e.uf_sigla AS SIGLA,
e.uf_descricao AS ESTADO
FROM
cep_endereco AS r
LEFT JOIN cep_bairro AS b ON b.bairro_codigo = r.bairro_codigo
LEFT JOIN cep_cidade AS c ON c.cidade_codigo = b.cidade_codigo
LEFT JOIN cep_uf AS e ON e.uf_codigo = c.uf_codigo
WHERE
c.cidade_codigo = '3169'";
$result = $Mysqli->query($query);
if($result->num_rows > 0){
$obj = $result->fetch_object();
$arr['result'] = true;
$arr['dados']['endereco']= $obj->ENDERECO;
}else{
$arr['result'] = false;
$arr['msg'] = "USUARIO INCORRETO";
}
}else{
$arr['result'] = false;
$arr['msg'] = $erro;
}
echo json_encode($arr);
?>
In the above query the intention is to return all addresses in a json, but this is only returning the first one, how could it all return?
Return current:
{"result":true,"dados":{"endereco":"RUA ABEL COUTO"}}