title: Dynamic menu with sub menus in HTML
body: <p>I've got a menu, that is something like this:</p>
  
  <pre><code>&lt;ul id="menu_cat"&gt;
      &lt;li&gt;&lt;a class="cat1" href="#"&gt;category 1&lt;/a&gt;
      &lt;ul&gt;
      &lt;li&gt;&lt;a class="cat2" href="#"&gt;category 2&lt;/a&gt;
          &lt;ul&gt;
              &lt;li&gt;&lt;a class="cat3" href="#"&gt;category 3&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a class="cat3" href="#"&gt;category 3&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a class="cat3" href="#"&gt;category 3&lt;/a&gt;&lt;/li&gt;
          &lt;/ul&gt;       
      &lt;/li&gt;
      &lt;li&gt;&lt;a class="cat2" href="#"&gt;Category 2&lt;/a&gt;
          &lt;ul&gt;
              &lt;li&gt;&lt;a class="cat3" href="#"&gt;category 3&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a class="cat3" href="#"&gt;category 3&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a class="cat3" href="#"&gt;category 3&lt;/a&gt;&lt;/li&gt;
          &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;&lt;a class="cat2" href="#"&gt;Category 2&lt;/a&gt;
          &lt;ul&gt;
              &lt;li&gt;&lt;a class="cat3" href="#"&gt;Category 3&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a class="cat3" href="#"&gt;category 3&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a class="cat3" href="#"&gt;category 3&lt;/a&gt;&lt;/li&gt;
          &lt;/ul&gt; 
      &lt;/li&gt;
      &lt;/ul&gt; &lt;!-- End of CAT1--&gt;
      &lt;/li&gt; &lt;!-- End of .Krmiva --&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>Now I need to make it dynamic, so the "Category 1, 2, 3" are taken from MySQL database, but I canť think of any other solution than making it something like 3 tables for CAT1, CAT2, CAT3 and than for every item in CAT1, selecting submenus from CAT2 and for every CAT2 selecting submenus from CAT3 ... which would mean to make like 20 <code>SELECT * FROM</code> queries.</p>
  
  <p>Any idea? Thanks, Mike.</p>