title: I want to display all sections from sections table for each classroom of classroom table with php mysql
body: <p>I have 2 tables:</p>
  <p>Classrooms (id, name) with 13 records.</p>
  <p>Sections (id, name, class_id) with 2 records for each classroom.</p>
  <p>I want to display all sections from sections table for each classroom of classrooms table with php mysql.</p>
  <p>I have 2 queries, one for each table with full join</p>
  <pre><code>SELECT * FROM classrooms
  JOIN sections ON sections.class_id=classrooms.id
  GROUP BY(sections.class_id)
  
  SELECT * FROM sections
  JOIN classrooms ON classrooms.id=sections.class_id 
  </code></pre>
  <p>my code is the following:</p>
  <pre><code> &lt;?php foreach($classrooms as $classe): ?&gt;
      &lt;div&gt;&lt;?php echo $classe['name']; ?&gt;&lt;/div&gt;
      &lt;?php foreach($sections as $section): ?&gt;
         &lt;?php if($section['class_id'] == $classe['id']) : ?&gt;
             &lt;div class=&quot;&quot;&gt;
                 &lt;div&gt;&lt;?php echo $section['name']; ?&gt;&lt;/div&gt;
             &lt;/div&gt;
         &lt;?php endif ?&gt; 
     &lt;?php endforeach ?&gt;
  </code></pre>
    
  <p>The problem it display the 2 sections for the first classroom and all the other classrooms are empty.</p>
  <p>Thanks</p>