-
Notifications
You must be signed in to change notification settings - Fork 1
/
search.php
32 lines (30 loc) · 1.23 KB
/
search.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
<?php
$sql = 'SELECT t.name as task_name, p.name as project_name, p.id as project_id, t.due_date as task_date, ' .
't.status as task_status, t.link_to_file as path, t.id as task_id ' .
'FROM tasks as t ' .
'JOIN projects as p ' .
'ON t.project_id = p.id ' .
'WHERE MATCH(t.name) AGAINST(?) AND t.user_id = ? ORDER BY t.date_of_create DESC';
$stmt = db_get_prepare_stmt($link, $sql, [$search, $current_user_id]);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
if ($result) {
$tasks_search = mysqli_fetch_all($result, MYSQLI_ASSOC);
if (count($tasks_search) === 0) {
$error_no_tasks = 'Задач не найдено';
}
$content = include_template('main.php', [
'tasks' => $tasks_search,
'tasks_for_counting' => $user_tasks,
'projects' => $projects,
'show_complete_tasks' => $show_complete_tasks,
'current_project_id' => $current_project_id,
'tasks_section' => $tasks_section,
'current_deadline' => $current_deadline,
'content_error_404' => $content_error_404,
'error_no_tasks' => $error_no_tasks
]);
} else {
$error = mysqli_error($link);
$content = include_template('error.php', ['error' => $error]);
}