-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathselect.php
More file actions
98 lines (93 loc) · 3.48 KB
/
select.php
File metadata and controls
98 lines (93 loc) · 3.48 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
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
<?php
include 'db.php';
$output = '';
if(isset($_POST["action"])){
$procedure ="
CREATE PROCEDURE selectTasks()
BEGIN
SELECT * FROM taskManager where status = 0 ORDER BY id DESC;
END;
";
if(mysqli_query($connect,"DROP PROCEDURE IF EXISTS selectTasks")){
if(mysqli_query($connect,$procedure)){
$query = "CALL selectTasks";
$result = mysqli_query($connect,$query);
$output .='
<table class="table table-borderd">
<tr>
<th>Project</th>
<th>Tasks</th>
<th>Update</th>
<th>Delete</th>
<th>Status</th>
</tr>
';
if(mysqli_num_rows($result) > 0){
while($row = mysqli_fetch_array($result)){
$output .='
<tr>
<td>'.$row["project_title"].'</td>
<td>'.$row["task"].'</td>
<td><button type="button" name="update" id="'.$row["id"].'" class="update btn btn-info">Update</button></td>
<td><button type="button" name="delete" id="'.$row["id"].'" class="delete btn btn-danger">Delete</button></td>
<td><button type="button" name="complete" id="'.$row["id"].'" class="complete btn btn-info">Done</button></td>
</tr>
';
}
}else{
$output ='
<tr>
<td><button type="button" project_title="Data not found" class="update btn btn-danger">Data not found - Please Add Some Tasks</button></td>
</tr>
';
}
$output .='</table>';
echo $output;
}
}
}
if(isset($_POST["actionComp"])){
$procedureComp ="
CREATE PROCEDURE selectCompletedTasks()
BEGIN
SELECT * FROM taskManager where status = 1 ORDER BY time DESC;
END;
";
if(mysqli_query($connect,"DROP PROCEDURE IF EXISTS selectCompletedTasks")){
if(mysqli_query($connect,$procedureComp)){
$query = "CALL selectCompletedTasks";
$result = mysqli_query($connect,$query);
$output .='
<table class="table table-borderd">
<tr>
<th>Project</th>
<th>Tasks</th>
<th>Status</th>
<th>Date</th>
<th>Delete</th>
</tr>
';
if(mysqli_num_rows($result) > 0){
while($row = mysqli_fetch_array($result)){
$output .='
<tr>
<td>'.$row["project_title"].'</td>
<td>'.$row["task"].'</td>
<td>'.$row["status"].'</td>
<td>'.$row["time"].'</td>
<td><button type="button" project_title="delete" id="'.$row["id"].'" class="delete btn btn-danger">Delete</button></td>
</tr>
';
}
}else{
$output ='
<tr>
<td><button type="button" project_title="Data not found" class="update btn btn-danger">Data not found - Please Add Some Tasks</button></td>
</tr>
';
}
$output .='</table>';
echo $output;
}
}
}