PageRenderTime 42ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/modules/snippets/ajax/snippet_results.php

https://bitbucket.org/websightdesigns/project-manager
PHP | 51 lines | 48 code | 0 blank | 3 comment | 4 complexity | 086b88ca947e4a74f4f4735f874e5a89 MD5 | raw file
  1. <?php
  2. include('../../../config.php');
  3. include('../../../includes/functions.php');
  4. include('../../../mysql.php');
  5. if ($link) {
  6. $level_auth = getCurrentUserAccessLevel();
  7. $group_auth = getCurrentUserGroupID();
  8. $return_arr = array();
  9. // projects
  10. $row_array = array();
  11. $projects_sql = "SELECT DISTINCT projects.project_name,
  12. projects.id
  13. FROM projects
  14. WHERE projects.project_name LIKE '%" . $_GET['term'] . "%'
  15. ORDER BY projects.project_name ASC";
  16. $projects_fetch = mysql_query($projects_sql);
  17. while ($projects_row = mysql_fetch_array($projects_fetch, MYSQL_ASSOC)) {
  18. $row_array['id'] = $projects_row['id'];
  19. $row_array['value'] = "Project: ".$projects_row['project_name'];
  20. array_push($return_arr,$row_array);
  21. }
  22. // clients
  23. $row_array = array();
  24. $clients_sql = "SELECT DISTINCT clients.fullname,
  25. clients.id
  26. FROM clients
  27. WHERE clients.fullname LIKE '%" . $_GET['term'] . "%'
  28. ORDER BY clients.fullname ASC";
  29. $clients_fetch = mysql_query($clients_sql);
  30. while ($clients_row = mysql_fetch_array($clients_fetch, MYSQL_ASSOC)) {
  31. $row_array['id'] = $clients_row['id'];
  32. $row_array['value'] = "Client: ".$clients_row['fullname'];
  33. array_push($return_arr,$row_array);
  34. }
  35. // tasks
  36. $row_array = array();
  37. $tasks_sql = "SELECT DISTINCT tasks.task_title,
  38. tasks.id
  39. FROM tasks
  40. WHERE tasks.task_title LIKE '%" . $_GET['term'] . "%'
  41. ORDER BY tasks.task_title ASC";
  42. $tasks_fetch = mysql_query($tasks_sql);
  43. while ($tasks_row = mysql_fetch_array($tasks_fetch, MYSQL_ASSOC)) {
  44. $row_array['id'] = $tasks_row['id'];
  45. $row_array['value'] = $tasks_row['task_title'];
  46. array_push($return_arr,$row_array);
  47. }
  48. }
  49. mysql_close($link);
  50. echo json_encode($return_arr);
  51. ?>