Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $itemId = $parentTicket[0]['id'];
- function bubbleSort(&$arr)
- {
- $n = sizeof($arr);
- for($i = 0; $i < $n; $i++)
- {
- for ($j = 0; $j < $n - $i - 1; $j++)
- {
- if ($arr[$j] > $arr[$j+1])
- {
- $t = $arr[$j];
- $arr[$j] = $arr[$j+1];
- $arr[$j+1] = $t;
- }
- }
- }
- }
- //$pos_sql = "select position from protocol_item where protocol_item.protocol = $itemId";
- $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";
- $arr = $global->db->getQuery($pos_sql);
- //$arr = array(64, 34, 25, 12, 22, 11, 90); // it's working
- $len = sizeof($arr);
- bubbleSort($arr);
- echo "Sorted array : n";
- for ($i = 0; $i < $len; $i++) {
- $final_position = $arr[$i];
- echo $final_position . " ";
- }
- Array
- (
- [0] => Array
- (
- [id] => 15
- [protocol] => 12
- [position] => 2
- [subject_item] =>
- [type] => D
- [responsible] => Chonchol
- [INSDATE] => 2019-07-03 11:33:13
- [body] => With responsible
- [participant] => Chonchol,Mahmud,more
- [subject] => Check for multi-participant final
- [status] => 0
- )
- [1] => Array
- (
- [id] => 16
- [protocol] => 12
- [position] => 2
- [subject_item] =>
- [type] => D
- [responsible] => Mahmud
- [INSDATE] => 2019-07-03 11:39:01
- [body] => With Responsible
- [participant] => Donald,Trump,Brad,Pitt
- [subject] => Check for multi-participant final
- [status] => 0
- )
- [2] => Array
- (
- [id] => 17
- [protocol] => 12
- [position] => 6
- [subject_item] =>
- [type] => I
- [responsible] => Testing
- [INSDATE] => 2019-07-03 11:43:01
- [body] => Another body bcfb
- [participant] =>
- [subject] => Check for multi-participant final
- [status] => 0
- )
- [3] => Array
- (
- [id] => 21
- [protocol] => 12
- [position] => 1
- [subject_item] => This is form Update
- [type] => S
- [responsible] => three
- [INSDATE] => 2019-07-13 04:39:10
- [body] => ffffffffffff
- [participant] =>
- [subject] => Check for multi-participant final
- [status] => 0
- )
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement