/modules/snippets/ajax/snippet_results.php
PHP | 51 lines | 48 code | 0 blank | 3 comment | 4 complexity | 086b88ca947e4a74f4f4735f874e5a89 MD5 | raw file
- <?php
- include('../../../config.php');
- include('../../../includes/functions.php');
- include('../../../mysql.php');
- if ($link) {
- $level_auth = getCurrentUserAccessLevel();
- $group_auth = getCurrentUserGroupID();
- $return_arr = array();
- // projects
- $row_array = array();
- $projects_sql = "SELECT DISTINCT projects.project_name,
- projects.id
- FROM projects
- WHERE projects.project_name LIKE '%" . $_GET['term'] . "%'
- ORDER BY projects.project_name ASC";
- $projects_fetch = mysql_query($projects_sql);
- while ($projects_row = mysql_fetch_array($projects_fetch, MYSQL_ASSOC)) {
- $row_array['id'] = $projects_row['id'];
- $row_array['value'] = "Project: ".$projects_row['project_name'];
- array_push($return_arr,$row_array);
- }
- // clients
- $row_array = array();
- $clients_sql = "SELECT DISTINCT clients.fullname,
- clients.id
- FROM clients
- WHERE clients.fullname LIKE '%" . $_GET['term'] . "%'
- ORDER BY clients.fullname ASC";
- $clients_fetch = mysql_query($clients_sql);
- while ($clients_row = mysql_fetch_array($clients_fetch, MYSQL_ASSOC)) {
- $row_array['id'] = $clients_row['id'];
- $row_array['value'] = "Client: ".$clients_row['fullname'];
- array_push($return_arr,$row_array);
- }
- // tasks
- $row_array = array();
- $tasks_sql = "SELECT DISTINCT tasks.task_title,
- tasks.id
- FROM tasks
- WHERE tasks.task_title LIKE '%" . $_GET['term'] . "%'
- ORDER BY tasks.task_title ASC";
- $tasks_fetch = mysql_query($tasks_sql);
- while ($tasks_row = mysql_fetch_array($tasks_fetch, MYSQL_ASSOC)) {
- $row_array['id'] = $tasks_row['id'];
- $row_array['value'] = $tasks_row['task_title'];
- array_push($return_arr,$row_array);
- }
- }
- mysql_close($link);
- echo json_encode($return_arr);
- ?>