Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.72 KB | None | 0 0
  1. $itemId = $parentTicket[0]['id'];
  2.  
  3. function bubbleSort(&$arr)
  4. {
  5. $n = sizeof($arr);
  6.  
  7. for($i = 0; $i < $n; $i++)
  8. {
  9. for ($j = 0; $j < $n - $i - 1; $j++)
  10. {
  11. if ($arr[$j] > $arr[$j+1])
  12. {
  13. $t = $arr[$j];
  14. $arr[$j] = $arr[$j+1];
  15. $arr[$j+1] = $t;
  16. }
  17. }
  18. }
  19. }
  20.  
  21. //$pos_sql = "select position from protocol_item where protocol_item.protocol = $itemId";
  22. $pos_sql = "SELECT item.id, item.protocol, item.position, item.subject_item, item.type, item.responsible, item.INSDATE, item.body, pp.participant, p.subject, p.status FROM protocol p LEFT JOIN protocol_item item ON item.protocol = p.id LEFT JOIN protocol_participant pp ON pp.itemid = item.id WHERE item.protocol = $itemId GROUP BY item.id";
  23. $arr = $global->db->getQuery($pos_sql);
  24. //$arr = array(64, 34, 25, 12, 22, 11, 90); // it's working
  25.  
  26. $len = sizeof($arr);
  27. bubbleSort($arr);
  28.  
  29. echo "Sorted array : n";
  30.  
  31. for ($i = 0; $i < $len; $i++) {
  32. $final_position = $arr[$i];
  33. echo $final_position . " ";
  34.  
  35. }
  36.  
  37. Array
  38. (
  39. [0] => Array
  40. (
  41. [id] => 15
  42. [protocol] => 12
  43. [position] => 2
  44. [subject_item] =>
  45. [type] => D
  46. [responsible] => Chonchol
  47. [INSDATE] => 2019-07-03 11:33:13
  48. [body] => With responsible
  49. [participant] => Chonchol,Mahmud,more
  50. [subject] => Check for multi-participant final
  51. [status] => 0
  52. )
  53.  
  54. [1] => Array
  55. (
  56. [id] => 16
  57. [protocol] => 12
  58. [position] => 2
  59. [subject_item] =>
  60. [type] => D
  61. [responsible] => Mahmud
  62. [INSDATE] => 2019-07-03 11:39:01
  63. [body] => With Responsible
  64. [participant] => Donald,Trump,Brad,Pitt
  65. [subject] => Check for multi-participant final
  66. [status] => 0
  67. )
  68.  
  69. [2] => Array
  70. (
  71. [id] => 17
  72. [protocol] => 12
  73. [position] => 6
  74. [subject_item] =>
  75. [type] => I
  76. [responsible] => Testing
  77. [INSDATE] => 2019-07-03 11:43:01
  78. [body] => Another body bcfb
  79. [participant] =>
  80. [subject] => Check for multi-participant final
  81. [status] => 0
  82. )
  83.  
  84. [3] => Array
  85. (
  86. [id] => 21
  87. [protocol] => 12
  88. [position] => 1
  89. [subject_item] => This is form Update
  90. [type] => S
  91. [responsible] => three
  92. [INSDATE] => 2019-07-13 04:39:10
  93. [body] => ffffffffffff
  94. [participant] =>
  95. [subject] => Check for multi-participant final
  96. [status] => 0
  97. )
  98.  
  99. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement