-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathlist-task.php
178 lines (103 loc) · 5.09 KB
/
list-task.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<?php
include('config/constants.php');
//Get the listid from URL
$list_id_url = $_GET['list_id'];
?>
<html>
<head>
<title>Task Manager with PHP and MySQL</title>
<link rel="stylesheet" href="<?php echo SITEURL; ?>css/style.css" />
</head>
<body>
<div class="wrapper">
<h1>TASK MANAGER</h1>
<!-- Menu Starts Here -->
<div class="menu">
<a href="<?php echo SITEURL; ?>">Home</a>
<?php
//Comment Displaying Lists From Database in ourMenu
$conn2 = mysqli_connect(LOCALHOST, DB_USERNAME, DB_PASSWORD) or die(mysqli_error());
//SELECT DATABASE
$db_select2 = mysqli_select_db($conn2, DB_NAME) or die(mysqli_error());
//Query to Get the Lists from database
$sql2 = "SELECT * FROM tbl_lists";
//Execute Query
$res2 = mysqli_query($conn2, $sql2);
//CHeck whether the query executed or not
if($res2==true)
{
//Display the lists in menu
while($row2=mysqli_fetch_assoc($res2))
{
$list_id = $row2['list_id'];
$list_name = $row2['list_name'];
?>
<a href="<?php echo SITEURL; ?>list-task.php?list_id=<?php echo $list_id; ?>"><?php echo $list_name; ?></a>
<?php
}
}
?>
<a href="<?php echo SITEURL; ?>manage-list.php">Manage Lists</a>
</div>
<!-- Menu Ends Here -->
<div class="all-task">
<a class="btn-primary" href="<?php echo SITEURL; ?>add-task.php">Add Task</a>
<table class="tbl-full">
<tr>
<th>S.N.</th>
<th>Task Name</th>
<th>Priority</th>
<th>Deadline</th>
<th>Actions</th>
</tr>
<?php
$conn = mysqli_connect(LOCALHOST, DB_USERNAME, DB_PASSWORD) or die(mysqli_error());
$db_select = mysqli_select_db($conn, DB_NAME) or die(mysqli_error());
//SQL QUERY to display tasks by list selected
$sql = "SELECT * FROM tbl_tasks WHERE list_id=$list_id_url";
//Execute Query
$res = mysqli_query($conn, $sql);
if($res==true)
{
//Display the tasks based on list
//Count the Rows
$count_rows = mysqli_num_rows($res);
if($count_rows>0)
{
//We have tasks on this list
while($row=mysqli_fetch_assoc($res))
{
$task_id = $row['task_id'];
$task_name = $row['task_name'];
$priority = $row['priority'];
$deadline = $row['deadline'];
?>
<tr>
<td>1. </td>
<td><?php echo $task_name; ?></td>
<td><?php echo $priority; ?></td>
<td><?php echo $deadline; ?></td>
<td>
<a href="<?php echo SITEURL; ?>update-task.php?task_id=<?php echo $task_id; ?>">Update </a>
<a href="<?php echo SITEURL; ?>delete-task.php?task_id=<?php echo $task_id; ?>">Delete</a>
</td>
</tr>
<?php
}
}
else
{
//NO Tasks on this list
?>
<tr>
<td colspan="5">No Tasks added on this list.</td>
</tr>
<?php
}
}
?>
</table>
</div>
</div>
</body>
</html>