php - How to show Factories for when specific User has logged in -
how add factory of logged in users? i'm using tank_auth , made account 'admin' made table called 'factoryusers'.
i want add factory specific user using joins.
my table structure:
users ----- id username email ... ... factories --------- idfactories factoryname adress ... ... factoryusers ------------ idfactoryusers idusers idfactories
i tried join these tables , show records factoryusers table.
my controller function:
$data['userbedrijf'] = $this->bedrijven_model->bedrijvenusers(); (translation english: $data['userfactory'] = $this->factory_model->factoryusers();)
my model:
function bedrijvenusers() { $this->db->join('bedrijven', 'bedrijfusers.idbedrijven = bedrijven.idbedrijven'); $this->db->join('users', 'bedrijfusers.idusers = users.id'); $result = $this->db->get('bedrijfusers', 1); return $result->result(); }
my views:
<h4>gebruikergegevens:</h4> <p class="field"><label class="field">gebruikersnaam:</label> <?= $this->tank_auth->get_username(); ?></p> <p class="field"><label class="field">emailadres:</label> <?= $user_data->email; ?></p> <p class="field"><label class="field">laatste login:</label> <?= date ("d-m-y h:i:s",strtotime($user_data->last_login)); ?></p> <p class="field"><label class="field">account aangemaakt:</label> <?= date ("d-m-y h:m:s",strtotime($user_data->created)); ?></p> <p class="field"><label class="field">laatst aangepast:</label> <?= date ("d-m-y h:i:s",strtotime($user_data->modified)); ?></p> <p class="field"><label class="field">is admin:</label> <?= $user_data->is_admin; ?></p> <hr> <h4>bedrijfsgegevens:</h4> <? foreach($userbedrijf $row){ ?> <p class="field"><label class="field">bedrijf_id:</label> <?= $row->idbedrijven; ?></p> <p class="field"><label class="field">bedrijfsnaam:</label> <?= $row->bedrijfsnaam; ?></p> <p class="field"><label class="field">adres:</label> <?= $row->adres; ?></p> <p class="field"><label class="field">postcode:</label> <?= $row->postcode; ?></p> <p class="field"><label class="field">plaats:</label> <?= $row->plaats; ?></p> <p class="field"><label class="field">telefoonnummer:</label> <?= $row->telefoonnummer; ?></p> <p class="field"><label class="field">website:</label> <?= $row->website; ?></p> <p class="field"><label class="field">email:</label> <?= $row->email; ?></p> <p class="field"><label class="field">profiel:</label> <?= $row->profiel; ?></p> <?}?>
what's wrong joins? shows me factories. each user factory same. when have multiple factoryuser rows in database different user id's , factory id's
the question not quite clear, should factories specified user, try it. kept original dutch/english names.
function bedrijvenuser($user_id) { $this->db->join('bedrijven', 'bedrijfusers.idbedrijven = bedrijven.idbedrijven', 'left'); $this->db->join('users', 'bedrijfusers.idusers = users.id'); return $this->db->get_where('bedrijfusers', array('idusers' => $user_id))->result(); }