Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [CodeIgniter]Grupowanie rekordów
Ambroz
post 20.08.2019, 21:35:29
Post #1





Grupa: Zarejestrowani
Postów: 1
Pomógł: 0
Dołączył: 20.08.2019

Ostrzeżenie: (0%)
-----


Witam szanowne forum.
Trafiłem na taki problem gdzie mam bazę danych w konfiguracji jak na obrazku a poniżej przedstawiam jak to wygląda i jak by to wyglądać miało.
Obecnie wygląda tak:
K1
U1

K2
U1

K1
U1

K2
U2

A właściwa reprezentacja ma wyglądać tak:

Kategoria 1
Użytkownik 1
Użytkownik 2

Kategoria 2
Użytkownik 1
Użytkownik 2

Z góry dziękuje za pomoc.

Screeny:
Tabela user_projects


Model:
CODE

  1. public function get_user_list(){
  2. $get_user =
  3. $this->db->SELECT('user.login_email, user.first_name, user.last_name, projects.project_name, department.department_name, user_group.user_group_name, is_active.active_name')
  4. ->FROM('user_projects')
  5. ->JOIN('user', 'id_user = user_id')
  6. ->JOIN('projects', 'id_project = projects_id')
  7. ->JOIN('department', 'id_department = department_id')
  8. ->JOIN('user_group', 'id_user_group = user_group_id')
  9. ->JOIN('is_active', 'id_is_active = is_active_id')
  10. ->get()->result();
  11. return $get_user;
  12. }



Widok:
CODE

  1. <div class="uk-container uk-container-center admin-content-wrapper user_list_wrapper">
  2. <section class="uk-grid">
  3. <div class="uk-width-1-1">
  4. <a class="uk-button uk-button-default" href="<?=base_url()?>administrator">Back</a>
  5. <a class="uk-button uk-button-default" href="<?=base_url()?>administrator/main/add_user">Add a User</a>
  6.  
  7.  
  8. <?php
  9. foreach($user_list as $key => $value){?>
  10. <ul uk-accordion>
  11. <li>
  12. <a class="uk-accordion-title" href="#"><?=$value->project_name;?></a>
  13.  
  14. <?php //foreach($user_list AS $list){?>
  15. <div class="uk-accordion-content">
  16.  
  17. <table>
  18. <tr>
  19. <th>First Name</th>
  20. <th>Last Name</th>
  21. <th>Login</th>
  22. <th>Department</th>
  23. <th>User Group</th>
  24. <th>Is Active</th>
  25. <th>Operations</th>
  26. </tr>
  27. <tr>
  28. <td><?=$value->first_name;?></td>
  29. <td><?=$value->last_name;?></td>
  30. <td><?=$value->login_email;?></td>
  31. <td><?=$value->department_name;?></td>
  32. <td><?=$value->user_group_name;?></td>
  33. <td><?=$value->active_name;?></td>
  34. <td><a class ="uk-button uk-button-default" href="<?=base_url()?>">Details</a></td>
  35. </tr>
  36. </table>
  37. </div>
  38. <?php break; ?>
  39. </li>
  40.  
  41. </ul>
  42. <?php }?>
  43. </div>
  44. </section>
  45. </div>

Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 29.03.2024 - 09:51