Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update get_project_details.php #24

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion projects/get_project_details.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,34 @@

echo json_encode($array);

function fetchProjectDetails($project_id) {
$stmt = $conn->prepare("SELECT project_name, project_location FROM projects WHERE project_id = ?");
$stmt->bind_param("i", $project_id);
$stmt->execute();
$stmt->bind_result($project_name, $project_location);
$stmt->fetch();
$stmt->close();

?>
$project_details = array(
"project_id" => $project_id,
"project_name" => $project_name,
"project_location" => $project_location
);
return $project_details;

}
if (isset($_GET['project_id'])) {
// Fetch project details using the provided project_id
$project_id = $_GET['project_id'];
$project_details = fetchProjectDetails($project_id);

// Convert the associative array to JSON and send as response
header('Content-Type: application/json');
echo json_encode($project_details);
} else {
// Send an error response if project_id is not provided
http_response_code(400);
echo json_encode(array("error" => "project_id parameter is missing"));
}

?>