title: Loop the subcategories, subcategories, etc
body: <pre><code>$sth = $db-&gt;query("SELECT * FROM categories WHERE parent = 0");
  
  $sth-&gt;setFetchMode(PDO::FETCH_ASSOC);
  
  while ($row = $sth-&gt;fetch()) {
  
     echo $row['title'] . '&lt;br /&gt;';
  
     $sth2 = $db-&gt;prepare("SELECT * FROM categories WHERE parent = ?");
     $sth2-&gt;bindParam(1, $row['id']);
     $sth2-&gt;execute();
  
     while ($row2 = $sth2-&gt;fetch()) {
          echo '..' . $row2['title'] . '&lt;br /&gt;';
  
          $sth3 = $db-&gt;prepare("SELECT * FROM categories WHERE parent = ?");
          $sth3-&gt;bindParam(1, $row2['id']);
          $sth3-&gt;execute();
  
          while ($row3 = $sth3-&gt;fetch()) {
              echo '....' . $row3['title'] . '&lt;br /&gt;';
          }
     }
  
  
  }
  </code></pre>
  
  <p>As you can see I have 'hard coded' every while loop for mainly a "main category", 'a subcategory' and finally it's subcategory.
  However I feel that I could change this, to automatically, loop the subcategories in the subcategories, if there are such.</p>
  
  <p>The structure is simple of my SQL:
  id
  parent
  title
  description</p>
  
  <p>I am clueless how I should solve this little problem... A while loop over a if-statement or something? Help me out.</p>