Welcome Guest, Not a member yet? Register   Sign In
Issue joining tables and running loops...
#1

[eluser]Kerran[/eluser]
First of all, to everyone who has contributed to this forum and the framework this is my first post and would you all to know that from a 'newbies' perspective the support and documentation provided for this framework is by far the best I have ever come across and it is all because of you...

I have minimal experience with Codeigniter and I have no problem getting this to work with other frameworks such as doctrine but I am finding it difficult getting it working with CI.

This is ultimately (in the most basic form).

I have a table of topics and a table of children topics with the primary key in the topics table matching a column in the children table.

In my web application is simply run a loop through all the topics and echo the children records related to that particular topic.

I am able to
1: pull information from one particular table
Code:
$this->db->select('*');
    $this->db->from('process');
2: left join the second table
Code:
$this->db->join('process_sub_categories', ' process_sub_categories.process_id = process.id', 'left');
3: run the query
Code:
$q = $this->db->get();
4: retun a variable
Code:
if ($q->num_rows() > 0) {
      foreach ($q->result() as $row) {
        $data[] = $row;
              
      }
      return $data;
    }

I need some support regarding how I can now run a foreach loop that assigns all the children topics to the appropriate parent.
so that output will look like this:

TOPIC A
CHILD A
CHILD B
TOPIC B
CHILD A
TOPIC C
CHILD A
CHILD B

apposed to

TOPIC A CHILD A
TOPIC A CHILD B
TOPIC B CHILD A
TOPIC C CHILD A
TOPIC C CHILD B

Any support will be appreciated.

Thank you very much.
Kerran


Messages In This Thread
Issue joining tables and running loops... - by El Forum - 08-10-2009, 07:02 PM
Issue joining tables and running loops... - by El Forum - 08-10-2009, 07:55 PM
Issue joining tables and running loops... - by El Forum - 08-10-2009, 11:21 PM
Issue joining tables and running loops... - by El Forum - 08-11-2009, 05:13 AM
Issue joining tables and running loops... - by El Forum - 08-11-2009, 01:38 PM



Theme © iAndrew 2016 - Forum software by © MyBB