-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path6-project_details.php
More file actions
37 lines (29 loc) · 981 Bytes
/
6-project_details.php
File metadata and controls
37 lines (29 loc) · 981 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
$servername = "localhost";
$username = "root"; // Replace with your database username
$password = ""; // Replace with your database password
$dbname = "mini_project";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Get the project ID from the URL
$project_id = isset($_GET['id']) ? $_GET['id'] : '';
// Prepare the SQL query to fetch the project details
$sql = "SELECT * FROM project_details WHERE project_id = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param('s', $project_id);
// Execute the statement
$stmt->execute();
$result = $stmt->get_result();
// Fetch the project details
$project = $result->fetch_assoc();
// Close connection
$stmt->close();
$conn->close();
// Return the project details as JSON
header('Content-Type: application/json');
echo json_encode($project);
?>