I want to fill an array with a query that I make from a table but I do not know how to format it correctly.
This is my PHP:
$consulta="SELECT * FROM registros2";
$registros=mysqli_query($conexion,$consulta) or die ("Problemas con la consulta");
while ($reg=mysqli_fetch_array($registros))
{
array_push($c,
$reg['id'],$reg['cliente'],$reg['metodo_pago'],$reg['hora'],$reg['fecha_entrega']);
}
When I print the result it looks like this:
[
"100",
"Carlos Luna",
"Credito 30D",
"14:15:00",
"2018-05-09",
"104",
"sadfsadf",
"Contado",
"12:32:00",
"2018-06-18"
]
And I need the format to be like this:
{
"data": [
[
"100",
"Carlos Luna",
"Credito 30D",
"14:15:00",
"2018-05-09"
],
[
"104",
"sadfsadf",
"Contado",
"12:32:00",
"2018-06-18"
]
]
}
Thank you in advance for your answers.