So i have this query:
select * from `sitios` INNER JOIN `imagens` ON sitios.id_sitio = imagens.id_sitio where sitios.id_sitio='1'
while ($row=mysqli_fetch_object($q)){
$data[]=$row;
}
if($q)
echo json_encode(array('status' => true, 'data' => $data));
else
echo json_encode(array('status' => false, 'data' => $data));
The result comes encoded in json since im using phonegap with framework7 and i can only use json.
This query will return this:
https://i.stack.imgur.com/sP0aV.jpg
As you can see, it returns the info about the "sitio" with the id of 1, but it return 3 "nome_imagem" that have different info. This is because this "place" as 3 images associated with it.
This is my ajax post to received the data from the query:
success: function(data) {
data = JSON.parse(data);
if (data['status']) {
$.each(data['data'], function(i, field) {
var id = field.id_sitio;
var nome = field.nome;
var descricao = field.descricao;
var img = field.img;
var morada = field.morada;
var email = field.email;
var telefone = field.telefone;
var facebook = field.facebook;
var website = field.website;
var coordenada_x = field.coordenada_x;
var coordenada_y = field.coordenada_y;
var imagens = field.nome_imagem;
console.log(imagens);
The problem is, the var "imagens" only contains 1 nome_imagem. How can i store all the info on variables like i have, but store on an array all the "nome_imagem" fields that come from the query?
Thanks in advance