-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblems.php
More file actions
55 lines (51 loc) · 1.7 KB
/
problems.php
File metadata and controls
55 lines (51 loc) · 1.7 KB
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
<?php
session_start();
include 'db_connect.php';
if (!isset($_SESSION['user_id'])) {
header("Location: login.php");
exit();
}
// Corrected table name from `problem` to `problems`
$sql = "SELECT p.*, c.category_name
FROM problems p
JOIN categories c ON p.category_id = c.category_id";
$result = $conn->query($sql);
if (!$result) {
die("Query failed: " . $conn->error); // Optional: helpful debug line
}
?>
<!DOCTYPE html>
<html>
<head>
<title>All DSA Problems</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css">
</head>
<body class="bg-light">
<div class="container mt-4">
<h2>All DSA Problems</h2>
<table class="table table-bordered mt-3">
<thead>
<tr>
<th>Title</th>
<th>Difficulty</th>
<th>Category</th>
<th>Source</th>
<th>Submit</th>
</tr>
</thead>
<tbody>
<?php while ($row = $result->fetch_assoc()): ?>
<tr>
<td><?= htmlspecialchars($row['title']) ?></td>
<td><?= htmlspecialchars($row['difficulty_level']) ?></td>
<td><?= htmlspecialchars($row['category_name']) ?></td>
<td><a href="<?= htmlspecialchars($row['source_link']) ?>" target="_blank">Link</a></td>
<td><a href="submit.php?problem_id=<?= $row['problem_id'] ?>" class="btn btn-success btn-sm">Submit</a></td>
</tr>
<?php endwhile; ?>
</tbody>
</table>
<a href="dashboard.php" class="btn btn-secondary">Back to Dashboard</a>
</div>
</body>
</html>