-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathprojectlist.php
70 lines (64 loc) · 2.03 KB
/
projectlist.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
<?php
require_once('connect.php');
session_start();
if (isset($_POST["keyword"])) {
$key = $_POST["keyword"];
$get_projects = "SELECT DISTINCT pid, pname, description, status FROM Project P LEFT JOIN ProjectTag USING(pid) WHERE tag LIKE '%$key%' OR pname LIKE '%$key%' OR description LIKE '%$key%' ORDER BY posttime DESC";
} elseif (isset($_GET["tag"])) {
$tag = $_GET["tag"];
$get_projects = "SELECT DISTINCT pid, pname, description, status FROM Project NATURAL JOIN ProjectTag WHERE tag='$tag' ORDER BY posttime DESC";
}
$projects = mysqli_query($conn, $get_projects);
if (!$projects) err_close();
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Project Search</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
</head>
<body>
<?php include_once('navbar.php') ?>
<div class="container">
<div class="panel panel-default">
<div class="panel-heading">
<?php if (isset($key)) {
echo "Search results for \"$key\"";
} elseif (isset($tag)) {
echo "Projects with tag \"$tag\"";
} echo " – newest first";
?>
</div>
<?php if (mysqli_num_rows($projects) > 0) { ?>
<table class="table table-striped table-bordered">
<thead>
<th>Project Name</th>
<th>Description</th>
<th>Status</th>
</thead>
<?php
while ($row = mysqli_fetch_assoc($projects)) {
$pid = $row['pid'];
?>
<tr>
<td>
<a href="project.php?pid=<?php echo $pid?>">
<?php echo $row['pname'] ?>
</a>
</td>
<td><?php echo $row['description'] ?></td>
<td><?php echo $row['status'] ?></td>
</tr>
<?php } ?>
</table>
<?php } else { ?>
<div class="panel-body">
No projects found.
</div>
<?php } ?>
</div>
</div>
</body>
</html>