-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathedit_project.php
101 lines (85 loc) · 2.94 KB
/
edit_project.php
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
session_start();
if (!isset($_SESSION['username'])) {
header("Location: login.php");
exit();
}
// Include the config file
require_once "config.php";
// Create connection
$conn = new mysqli($host, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Get user ID from username
$sql = "SELECT uid FROM users WHERE username = '" . $_SESSION['username'] . "'";
$result = $conn->query($sql);
$row = $result->fetch_assoc();
// Get search query, if any
$search_query = isset($_GET['q']) ? $_GET['q'] : '';
// Prepare SQL statement
$sql = "SELECT pid, title, start_date FROM projects WHERE uid = " . $row['uid'] . " AND (title LIKE '%" . $search_query . "%' OR start_date LIKE '%" . $search_query . "%')";
// Execute SQL statement
$result = $conn->query($sql);
// Close connection
$conn->close();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Edit Project</title>
<link rel="stylesheet" href="css/[email protected]">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Montserrat&family=Open+Sans&display=swap" rel="stylesheet">
</head>
<body>
<div class="container">
<h1>Select a project to edit</h1>
</div>
<div class="search-container">
<form action="edit_project.php" method="GET">
<input type="text" name="q" placeholder="Search by title or start date"
value="<?php echo $search_query; ?>">
<button type="submit">Search</button>
</form>
</div>
<div class="table-container">
<table>
<tr>
<th>Title</th>
<th>Start Date</th>
</tr>
<?php
if ($result->num_rows > 0) {
// Output data of each row
while ($row = $result->fetch_assoc()) {
echo "<tr onclick=\"location.href='edit_project_details.php?pid=" . $row["pid"] . "'\">";
echo "<td>" . $row["title"] . "</td>";
echo "<td>" . $row["start_date"] . "</td>";
echo "</tr>";
}
} else {
echo "<tr><td colspan='2'>No results found</td></tr>";
}
?>
</table>
</div>
<div class="button-container">
<button class="button" onclick="window.location.href='logged_in.php'">Back</button>
</div>
<footer>
<div class="logo-container">
<a href="index.php">
<img src="img/ap.svg" alt="logo">
</a>
</div>
<div class="footer-text">
<span>©2023 M Kalam | [email protected]</span>
</div>
</footer>
</body>
</html>