-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
64 lines (58 loc) · 1.95 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
<?php
$connection = require_once './Connection.php';
$notes = $connection->getNotes();
$currentNote = ['id' => '','title' => '', 'description' => ''];
if (isset($_GET['id'])) {
$currentNote = $connection->getNoteById($_GET['id']);
}
//echo '<pre>';
//var_dump($notes);
//echo '</pre>';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link rel="stylesheet" href="app.css">
</head>
<body>
<div>
<form class="new-note" action="save.php" method="post">
<input type="hidden" name="id" value="<?php echo $currentNote['id'] ?>">
<input type="text" name="title" placeholder="Note title"
autocomplete="off" value="<?php echo $currentNote['title']?>">
<textarea name="description" cols="30" rows="4"
placeholder="Note Description"><?php echo $currentNote['description']?></textarea>
<button>
<?php if ($currentNote['id']): ?>
Update Note
<?php else: ?>
New Note
<?php endif; ?>
</button>
</form>
<div class="notes">
<?php foreach ($notes as $note): ?>
<div class="note">
<div class="title">
<a href="?id=<?php echo $note['id'] ?>">
<?php echo ($note['title'] != '') ? $note['title'] : 'Title' ?>
</a>
</div>
<div class="description">
<?php echo $note['description'] ?>
</div>
<small><?php echo $note['create_date'] ?></small>
<form action="delete.php" method="post">
<input type="hidden" name="id" value="<?php echo $note['id'] ?>">
<button class="close">X</button>
</form>
</div>
<?php endforeach; ?>
</div>
</div>
</body>
</html>