connect(); $project = new Project($db); $project->pid = $data->id; $result = $project->detail(); $num = $result->rowCount(); $tempObject = new stdClass(); $tempObject->data = NULL; if ($num > 0) { $row = $result->fetch(PDO::FETCH_ASSOC); extract($row); $surveyEntry = NULL; $clientAttribute = $liveAttributes ? $liveAttributes : "[CLIENT-ATTRIBUTE]"; $clientPlacholder = "&" . $clientAttribute . "=xxxx"; $item = array( "id" => $pid, "name" => $name, "liveAttributes" => $liveAttributes, "stats" => array( "total" => (int)$total, "open" => (int)$open, "started" => (int)$started, "complete" => (int)$complete, "screenout" => (int)$screenout, "quotafull" => (int)$quotafull ), "redirects" => array( "complete" => str_replace("{pid}", $pid, COMPLETE_REDIRECT) . $clientPlacholder, "quotafull" => str_replace("{pid}", $pid, QUOTAFULL_REDIRECT) . $clientPlacholder, "screenout" => str_replace("{pid}", $pid, SCREENOUT_REDIRECT) . $clientPlacholder ), ); $tempObject->data = $item; } echo json_encode($tempObject);