How to reference the value of a result in a second query |
Hi everyone, I am new to PHP and codeigniter...
I have two tables one stores the name of different id and organization name second table contains people information with id for the organization they belong to I want to translate the name of the organization for each person from the organization table matching it on the organization id I know how to write the query however, I am unable to figure out how to reference the organization id as part of a result set i.e. $org_ID = $row->org_ID; $query = $this->db->get_where('organization', array('orgID' => $org_ID); <<<<<< this does not work and I do not know how foreach ($query->result() as $r) <<<<< reference the $row->org_ID in the query {?> <td><?php echo $r->orgName;?></td> <<<<<<<< this is what I ultimately want to name of the organization and not it's <?php } ?> <<<<<<<< record identifier. Can anyone show me how to reference the data in the result set in a second query? I would be so thankful...
You can use one to many relationship, so the table must look like this below,
Code: Organization The Query Code: function get_record_by_id($person_id) Not tested buy try...
No SEO spam
(12-12-2015, 04:04 PM)solidcodes Wrote: You can use one to many relationship, so the table must look like this below, thank you very much for your help.. sorry it took so long to get back here but life happens.. again thanks much |
Welcome Guest, Not a member yet? Register Sign In |