Bonjour,
je suis débutante en développement web, et j'ai besoin d'aide s'il vous plait.
D'abord, j'ai un base de données qui avait trois tables et je fait un jointure entre trois tables. je veux récupérer le id dans le table commun , nomRegion dans le table région et nomDistrict dans le district des trois tables. L'id du table region et district sont liées avec le commun. Et je veux que l'id du table commun soit cacher. Et je veux afficher le nomRegion et nomDistrict dans un tableau.
Mon model
Code php : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 public function findAll($start, $offset) { $this->db->select('commun.id, region.nomRegion, district.nomDistrict'); $this->db->from('commun'); $this->db->join('region', 'commun.region=region.id'); $this->db->join('district', 'commun.district=district.id'); $this->db->get(); $sql = $this->db->last_query(); $query = $this->db->query($sql); return $query->result_array(); }
Mon controlleur
Code php : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 <?php defined('BASEPATH') OR exit('No direct script access allowed'); /** * */ class Auth extends CI_Controller { function Auth() { parent::__construct(); $this->load->helper('form'); $this->load->model('users_model'); $this->load->helper('html'); $this->load->library('form_validation');//mcharger form_validation any am library $this->load->library('pagination'); } ...... ..... function liste_os(){ $page = $this->uri->segment(4,0); $config['per_page'] = '100'; $config['uri_segment'] = 4; $commun = $this->users_model->findAll($config['per_page'],$page); $view_setup['listecommun'] = $commun; $view_setup['uid'] = $this->session->userdata('user_id'); $view_setup['user_name'] = $this->session->userdata('user_name'); $this->load->view('common/header.php', $view_setup); $this->load->view('common/menu.php', $view_setup); $this->load->view('listeMenu/listeOs.php', $view_setup); $this->load->view('common/footer.php', $view_setup); }
Mon vue
Code php : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41 <div class="row"> <div class="col-md-12" > <h1>REGION</h1> <table id = "book-table" class = "table table-bordered table-striped table-hover"> <thead> <tr> <th>Region</th> <th>District </th> <th>Nombres OS</th> <th>Nombres commun</th> </tr> <?php $nbLigne=0; foreach ($listecommun as $comm=>$co): foreach ($co as $c): ?> <tr> <th> <?php echo $c->nomRegion; ?> </th> <th> <?php echo $c->nomDistrict; ?> </th> </tr> <?php endforeach; endforeach; ?> </tr> </thead> <tbody> </tbody> </table> </div> </div>
Quand je mis le
Code php : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7 <th> <?php echo $c->nomRegion; ?> </th> <th> <?php echo $c->nomDistrict; ?> </th>
Il y a toujours ce message d'erreur
Message: Trying to get property of non-object
Et quand je fais juste
Il affiche tous les trois . Aide-moi s'il vous plait
Code php : Sélectionner tout - Visualiser dans une fenêtre à part <?php echo $c ?>
Partager