-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathindex.php
135 lines (90 loc) · 2.52 KB
/
index.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
<?php
session_start();
require_once "header.php";
?>
<div class="container">
<div class="row">
<div class="col-8 m-auto">
<h2 class="display-4 text-center" >My To Do List</h2>
<form class="mt-4" action="index_valid.php" method="post">
<div class="form-group">
<input class= "form-control form-control-lg" type="text" name="textfield" placeholder="Enter your task" >
</div>
<div class="">
<input class="btn btn-success btn-block" type="submit" name="addtask" value="Add Task">
</div>
</form>
</div>
</div>
<!-- ===================== show delete alert message ============= -->
<?php
if(isset($_SESSION['delete_success'])) { ?>
<div class="alert alert-warning text-dark mx-auto mt-4" role="alert" style="width:66%;">
<?=$_SESSION['delete_success'];?>
</div>
<?php
unset($_SESSION['delete_success']);
}
?>
<!-- ========================== update alert message ==================== -->
<?php
if(isset($_SESSION['upadate_success'])) { ?>
<div class="alert alert-warning text-dark mx-auto mt-4" role="alert" style="width:66%;">
<?=$_SESSION['upadate_success'];?>
</div>
<?php
unset($_SESSION['upadate_success']);
}
?>
<!-- =================================== table =========================== -->
<table style="width:66%;" class="table table-sm table-borderless table-striped text-center mx-auto mt-3" >
<thead class="bg-dark text-white text-center">
<tr>
<th>Serial</th>
<th>task</th>
<th>added date</th>
<th>added time</th>
<th>action </th>
</tr>
</thead>
<?php
require_once "db.php";
$task_show_query = "SELECT * FROM task_table";
$result = $dbcon -> query($task_show_query);
if($result->num_rows!=0){
$serial = 1;
foreach ($result as $row) {
$temp_date_time=(explode(' ',$row['added_tiime']));
$date = $temp_date_time[0];
$time = $temp_date_time[1];
?>
<tr>
<td><?=$serial++?></td>
<td ><?=$row['task_name'] ?></td>
<td><?=$date?></td>
<td><?=$time?></td>
<td>
<div class="btn-group">
<a class="btn btn-sm btn-warning" href="update.php?id=<?php echo base64_encode($row['id']); ?>">update</a>
<a class="btn btn-sm btn-danger" href="delete.php?id=<?php echo base64_encode($row['id']); ?>">delete</a>
</div>
</td>
</tr>
<?php
}
}
// ========================== if no data found ========================
else{
?>
<tr>
<td colspan="20" class="text-center display-4" >No task</td>
</tr>
<?php
}
?>
</table>
<!-- </div>
</div> -->
<!-- </div> -->
</body>
</html>