You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.1 KiB
38 lines
1.1 KiB
<?php
|
|
require "header.php";
|
|
function html_escape($text){
|
|
return htmlspecialchars((string)$text,ENT_QUOTES, "UTF-8");
|
|
}
|
|
$tasks = [];
|
|
try {
|
|
$query = $pdo->prepare("SELECT id, task_desc
|
|
FROM tasks ORDER BY created ASC");
|
|
$query->execute();
|
|
$tasks = $query->fetchAll(PDO::FETCH_ASSOC);
|
|
} catch (PDOException $e) {
|
|
echo '<div class="alert alert-danger"> Chyba při
|
|
načítní úkolů' . html_escape($e->getMessage());
|
|
}
|
|
?>
|
|
<h4 class="display-4">Moje úkoly</h4>
|
|
|
|
<form action="add_task.php" method="post" class="card card-body
|
|
bg-light mb-3">
|
|
<div class="m-3">
|
|
<label for="task_desc" class="form-label">Nový úkol:</label>
|
|
<input type="text" class="form-control"
|
|
id="task_desc" name="task_desc"
|
|
required placeholder="Nový úkol..">
|
|
</div>
|
|
<button type="submit" class="btn btn-primary">Přidat úkol</button>
|
|
</form>
|
|
|
|
|
|
<ul class="list-group">
|
|
<?php foreach($tasks as $task):?>
|
|
<li class="list-group-item d-flex
|
|
justify-content-between align-items-center">
|
|
<span><?= html_escape($task["task_desc"])?></span>
|
|
</li>
|
|
<?php endforeach?>
|
|
</ul>
|