I have the following code, but it does not show it to me as a json array, how can I modify it so that it is an array type array= [{"nombre":"jesus"}]
etc etc.
$result = mysqli_query($connect, "SELECT * FROM 'transacciones' WHERE 'Usercorreo' = '$Username'");
$existsql = mysqli_affected_rows($connect);
if ($existsql > 0) {
$resultado = mysqli_query($connect, "SELECT * FROM 'transacciones' WHERE 'Usercorreo' = '$Username' AND tipo='$tipo'");
while($array=mysqli_fetch_array($resultado)){
$response["idTrans"] = $array['idTrans'];
//$response["ComCorreo"] = $array['ComCorreo'];
$ComCorreo = $array['ComCorreo'];
$response["monto"] = $array['monto'];
$response["fecha"] = $array['fecha'];
$response["concepto"] = $array['concepto'];
//echo json_encode($response);
$comrsql=mysqli_query($connect,"SELECT * FROM 'comercios' WHERE 'Comcorreo'='$ComCorreo'");
while($rowid=mysqli_fetch_array($comrsql)){
$response["COMERCIONOMBRE"] =$rowid['nombre'];
$response["COMERCIORIF"] =$rowid['rif'];
$response["COMERCIOLOGO"] =$rowid['logo'];
echo json_encode($response);
}
}
} else {
$response["success"]=false;
$response["error"] = "NOHAYTRANSACCIONES";
}
$response["success"]=true;
mysqli_close($connect);
At this moment the result is structured like this:
{
"idTrans": "1",
"monto": "5998.89",
"fecha": "2017-08-15",
"concepto": "",
"COMERCIONOMBRE": "Fitness Universal",
"COMERCIORIF": "402123693",
"COMERCIOLOGO": "logo\/1.png"
}
but it is not how the array should show me, that I must modify in my code taking into account that I consult two tables instead of one.