I have the following query in php:
$SQL_select="SELECT SUM(TIMESTAMPDIFF(minute, reserva_estacionamiento.hora_reserva,reserva_estacionamiento.hora_salida) * estacionamiento.tarifa) as resultado
FROM reserva_estacionamiento inner join estacionamiento
WHERE reserva_estacionamiento.id_reserva='$idreserva' and estacionamiento.id_estacionamiento='$idestacionamiento'";
$statement = $db->prepare($SQL_select);
$statement->execute(); // no need to add '$sql' here, you can take that out
$item_id = $statement->fetchColumn();
echo $item_id;
echo json_encode($item_id);
How to send the variable $ item_id to a json or how to retrieve the variable from json, thanks in advance.