0
Hello, I have a problem, this code below is returning a 'type' object, I need 'type' to be array.
while ($obj = $stmt->fetch(PDO::FETCH_ASSOC)) {
$stmt2 = $db->query('SELECT * FROM wines a, uva b WHERE a.id_tipo = '.$obj['idtipo'].' AND a.id_uva = b.id GROUP BY a.id_uva');
while ($obj2 = $stmt2->fetch(PDO::FETCH_ASSOC)) {
$wines[$obj['tipo']][] = $obj2;
}
}
He returns like this
{"ESPUMANTES": [
{
"id": "5",
"name": "MIOLO MILESSIME",
"uva": "BRUT"
},
],
"VINHOS BRANCOS": [
{
"id": "1",
"name": "CASA VALDUGA LEOPOLDINA GRAN RESERVA",
"uva": "CHARDONNAY"
},
]}
I need "SPARKLING" and "WHITE WINES" to be inside an array.
{
[
1: "ESPUMANTES" [
{
"id": "1",
"name": "CASA VALDUGA LEOPOLDINA GRAN RESERVA",
"uva": "CHARDONNAY"
}
]
],
[
2: "VINHOS BRANCOS" [
{
"id": "1",
"name": "CASA VALDUGA LEOPOLDINA GRAN RESERVA",
"uva": "CHARDONNAY"
}
]
}
If I understand correctly. You want it to stay that way:
array("ESPUMANTES", "VINHOS BRANCOS")
. That’s it?– Andrei Coelho
basically that, but within each other array with the information
– Patric Pippi
For each wine can it have more than one category? That’s it?
– Andrei Coelho
Example... MIOLO MILESSIME can be "SPARKLING" and "WHITE WINES". That’s it?
– Andrei Coelho
You could show the desired end result?
– Andrei Coelho
something like this, why I need to iterate it at the angle with ngFor the types of wines that are SPARKLING WINES or WHITE WINES, in a list that opens a modal with the wines themselves.
– Patric Pippi
I get it. I’ll post an answer and you’ll see if it works.
– Andrei Coelho