Why build the json data manually???
$json_data = json_encode($result);
AS for the rest of the code, without knowing your db structure and gantt api input requirements there is no way I can suggest a better route.
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.