title: Generating multiple query results using Foreach Loop in one variable
body: <p>I'm working on a php project using codeigniter but I'm stuck on mysql query since the last 2 days without finding any solution. The problem is that I have <code>02 Mysql</code> tables that I want to get results from using a variable from the <code>url</code> but I need to generate multiple results from the first query and get multiple results on the second query using the first query results, it's a little bit complicated because I can't find out a better way to describe the problem but here's the first table :</p>
  
  <pre><code>Table  
  
  +---------------+-------------+------+-----+---------+
  | Field         | Type        | Null | Key | Default |
  +---------------+-------------+------+-----+---------+
  | nApplication  | int(11)     | NO   | MUL | NULL    |
  | nProduct      | int(11)     | NO   |     | 1       |
  +---------------+-------------+------+-----+---------+
  </code></pre>
  
  <p>I've <strong>multiple</strong> <code>nApplication</code> values that have the same <code>nProduct</code> (<strong>the variable from the url</strong>) and I want to get all the row from this table : </p>
  
  <pre><code>Table : tapplication
  
  +---------------+---------------------+------+-----+---------+----------------+
  | Field         | Type                | Null | Key | Default | Extra          |
  +---------------+---------------------+------+-----+---------+----------------+
  | nApplication  | int(11)             | NO   | PRI | NULL    | auto_increment |
  | nStatus       | tinyint(3) unsigned | NO   | MUL | 1       |                |
  | nManufacturer | int(11)             | NO   | MUL | 1       |                |
  | nSerie        | int(11)             | NO   | MUL | 1       |                |
  | sType         | varchar(48)         | NO   |     | #       |                |
  | sDate1        | varchar(6)          | NO   |     | #       |                |
  | sDate2        | varchar(6)          | NO   |     | #       |                |
  | sEngine       | varchar(48)         | NO   |     | #       |                |
  | sKiloWatt     | varchar(6)          | NO   |     | #       |                |
  | sHorsePower   | varchar(6)          | NO   |     | #       |                |
  +---------------+---------------------+------+-----+---------+----------------+
  </code></pre>
  
  <p>That have the same <code>nApplication</code> from the previous query.</p>
  
  <h1>The Query I have so fare (Model)</h1>
  
  <pre><code>function getApplication($product_id){
        $this-&gt;db-&gt;from('tapplicationproduct')
                 -&gt;where('nProduct',$product_id);
                 $query = $this-&gt;db-&gt;get();
                 foreach ($query-&gt;result() as $row) {
                  $ret['napp'] = $row['nApplication'];
                 }
        return $ret;
      }
  </code></pre>
  
  <p>I can't figure out to get how to get the Application results from the <code>tapplication</code> tables using the above query results</p>