-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathmanage-list.php
148 lines (108 loc) · 5.03 KB
/
manage-list.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
148
<?php
include('config/constants.php');
?>
<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>
<a class="btn-secondary" href="<?php echo SITEURL; ?>">Home</a>
<h3>Manage Lists Page</h3>
<p>
<?php
//Check if the session is set
if(isset($_SESSION['add']))
{
//display message
echo $_SESSION['add'];
//REmove the message after displaying one time
unset($_SESSION['add']);
}
//Check the session for Delete
if(isset($_SESSION['delete']))
{
echo $_SESSION['delete'];
unset($_SESSION['delete']);
}
//Check Session Message for Update
if(isset($_SESSION['update']))
{
echo $_SESSION['update'];
unset($_SESSION['update']);
}
//Check for Delete Fail
if(isset($_SESSION['delete_fail']))
{
echo $_SESSION['delete_fail'];
unset($_SESSION['delete_fail']);
}
?>
</p>
<!-- Table to display lists starts here -->
<div class="all-lists">
<a class="btn-primary" href="<?php echo SITEURL; ?>add-list.php">Add List</a>
<table class="tbl-half">
<tr>
<th>S.N.</th>
<th>List Name</th>
<th>Actions</th>
</tr>
<?php
//Connect the DAtabase
$conn = mysqli_connect(LOCALHOST, DB_USERNAME, DB_PASSWORD) or die(mysqli_error());
//Select Database
$db_select = mysqli_select_db($conn, DB_NAME) or die(mysqli_error());
//SQl Query to display all data fromo database
$sql = "SELECT * FROM tbl_lists";
//Execute the Query
$res = mysqli_query($conn, $sql);
//CHeck whether the query executed executed successfully or not
if($res==true)
{
//work on displaying data
//echo "Executed";
//Count the rows of data in database
$count_rows = mysqli_num_rows($res);
//Create a SErial Number Variable
$sn = 1;
//Check whether there is data in database of not
if($count_rows>0)
{
//There's data in database' Display in table
while($row=mysqli_fetch_assoc($res))
{
//Getting the data from database
$list_id = $row['list_id'];
$list_name = $row['list_name'];
?>
<tr>
<td><?php echo $sn++; ?>. </td>
<td><?php echo $list_name; ?></td>
<td>
<a href="<?php echo SITEURL; ?>update-list.php?list_id=<?php echo $list_id; ?>">Update</a>
<a href="<?php echo SITEURL; ?>delete-list.php?list_id=<?php echo $list_id; ?>">Delete</a>
</td>
</tr>
<?php
}
}
else
{
//No Data in Database
?>
<tr>
<td colspan="3">No List Added Yet.</td>
</tr>
<?php
}
}
?>
</table>
</div>
<!-- Table to display lists ends here -->
</div>
</body>
</html>