-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotes.php
210 lines (151 loc) ยท 4.75 KB
/
notes.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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<?php
require_once("./configurations/conn.php");
if (!$isLogin) {
home();
exit;
}
// ? Get user
$ID = get_id_header('id');
if ($ID) {
$queryGetAllNotes = "SELECT * FROM note WHERE `uid` = '$ID' ";
$allNotes = mysqli_query($conn, $queryGetAllNotes);
if (!$allNotes) {
# code...
home();
exit;
}
$queryGetCount = "SELECT COUNT(*) as `count` FROM note WHERE `uid` = '$ID'";
$countAllNotes = mysqli_query($conn, $queryGetCount)->fetch_assoc();
}
function refresh()
{
Locatoin('notes.php?id=' . get_session('id'));
}
// ? Start Actoin Query
if ($_SERVER["REQUEST_METHOD"] == "GET") {
if (isset($_GET['remove']) != '') {
$id_Remove = get_id_header('remove');
$queryRemoveNote = "DELETE FROM note WHERE `id`='$id_Remove'";
$resultNewNote = mysqli_query($conn, $queryRemoveNote);
if ($resultNewNote) {
refresh();
}
}
//hearts
if (isset($_GET['heart']) != '') {
$id_Heart = get_id_header('heart');
$statusNote = 'true';
while ($note = $allNotes->fetch_assoc()) {
if ($id_Heart == $note['id']) {
$statusNote = ($note['status'] == 'false') ? 'true' : 'false';
}
}
$queryChangeStatus = "UPDATE `note` SET `status`='$statusNote' WHERE `id`='$id_Heart' ";
$resultStatus = mysqli_query($conn, $queryChangeStatus);
if ($resultStatus) {
refresh();
}
}
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (isset($_POST['delete-all'])) {
$queryDeleteAllNotes = "DELETE FROM note WHERE `uid`='$ID'";
$result = mysqli_query($conn, $queryDeleteAllNotes);
if ($result) {
refresh();
}
}
if (isset($_POST['delete'])) {
home();
}
}
$countLovePage = 0;
$countNowPage = 0;
$page_type = 'notes';
include_once("./includes/header.php");
?>
<body>
<?php include_once('./includes/Navbar.php'); ?>
<?php include_once('./includes/NoteCard.php'); ?>
<ul class="bg-indigo-800 rounded-full mx-auto h-10 text-white p-1 grid grid-cols-3 justify-evenly w-[340px] text-xs my-10">
<li class="nav-item flex__center rounded-full">
<button class="nav-link" page="love-page">ุนูุงููู
ูุฏู</button>
</li>
<li class="nav-item flex__center active-link rounded-full">
<button class="nav-link" page="note-page">ูุงุฏุฏุงุดุช</button>
</li>
<li class="nav-item flex__center rounded-full">
<button class="nav-link" page="now-page">ูุงุฏุฏุงุดุช ุงู
ุฑูุฒ</button>
</li>
</ul>
<section class="mx-auto max-w-7xl px-6 lg:px-8">
<div class="container content-note mt-5" id="note-page">
<center>
<div class="grid grid-cols-1 lg:grid-cols-3 md:grid-cols-2 gx-4">
<?php
while ($note = $allNotes->fetch_assoc()) {
noteCard($note, $ID);
}
$allNotes->data_seek(0);
?>
</div>
</center>
<?php
if ($countAllNotes['count'] != '0') {
counterNotes($countAllNotes['count']);
} else {
alertNotNotes();
}
?>
</div>
<div class="container content-note mt-5" id="love-page" hidden>
<center>
<div class="grid grid-cols-1 lg:grid-cols-3 md:grid-cols-2 gx-4">
<?php
while ($note = $allNotes->fetch_assoc()) {
if ($note['status'] == 'true') {
noteCard($note, $ID);
$countLovePage++;
}
}
$allNotes->data_seek(0);
?>
</div>
</center>
<?php
if ($countLovePage != 0) {
counterNotes($countLovePage);
} else {
alertNotNotes();
}
?>
</div>
<div class="container content-note mt-5" id="now-page" hidden>
<center>
<div class="grid grid-cols-1 lg:grid-cols-3 md:grid-cols-2 gx-4">
<?php
while ($note = $allNotes->fetch_assoc()) {
if (substr($note['updateAt'], 0, 10) == $Today) {
noteCard($note, $ID);
$countNowPage++;
}
}
?>
</div>
</center>
<?php
if ($countNowPage != 0) {
counterNotes($countNowPage);
} else {
alertNotNotes();
}
?>
</div>
</section>
<?php include_once('./includes/comments.php'); ?>
<?php include_once('./includes/footer.php'); ?>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-w76AqPfDkMBDXo30jS1Sgez6pr3x5MlQ1ZAGC+nuZB+EYdgRZgiwxhTBTkF7CXvN" crossorigin="anonymous"></script>
<script src="./js/main.js"></script>
<script src="./js/notes.js"></script>
</body>
</html>