title: Query from two db tables with php
body: <p>I have these two tables:</p>
  <p>Table 1:</p>
  <pre><code>PRESETS
  - id
  - image
  - url
  - name
  - collectionID
  </code></pre>
  <p>Table 2:</p>
  <pre><code>COLLECTION
  - id
  - collection_name
  </code></pre>
  <p>I'm trying to print with PHP a thing like:</p>
  <pre><code>COLECTION NAME
  Image1 image2 image3 image4 image5
  
  COLECTION NAME2
  Image1 image2 image3 image4 image5
  </code></pre>
  <p>and so on...</p>
  <p>I'm trying to figure out how to make this code run. It doesn't print anything...</p>
  <pre><code>&lt;?php
              $sql = &quot;SELECT collection.id, collection.name
      FROM `collection`
      ORDER BY collection.id DESC&quot;;
  $categories = $mysqli -&gt; query($sql);
  foreach($categories as $cat) {
  echo '&lt;li&gt;&lt;a href=&quot;#&quot;&gt;' . $cat[1] . '&lt;/a&gt;&lt;ul&gt;';
  $sql2 = &quot;SELECT presets.preview, presets.seoName
          FROM `presets`
          WHERE `presets`.collectionID = &quot;.$cat[0];
  $products = execute_select($sql2);
  foreach($products as $prod) {
      echo '&lt;li&gt;&lt;a href=&quot;&amp;id=' . $prod[1] . '&quot;&gt;' . $prod[0] . '&lt;/a&gt;&lt;/li&gt;';
  }
  echo '&lt;/ul&gt;&lt;/li&gt;';
  }
              ?&gt;
  </code></pre>
  <p>But I can't figure out how to get data as described above. What kind of query can I make?</p>