title: menu with submenu using mysql
body: <p>Hello I just a little but help.</p>
  
  <p>What I am trying to do is create a menu with a submenu by getting the data from 2 different mysql tables.</p>
  
  <p>The issue I am having is the submenu will not display all results from the "Sub Category" database depending on what page I am on</p>
  
  <p>Table 1: Category "ID, Name"</p>
  
  <p>Table 2: Sub Category "ID, Name, Cparent, filename (Image for sub category)"</p>
  
  <p>I have the following code:</p>
  
  <pre><code>&lt;ul&gt;
  &lt;?php 
    $catmenu_sql = 'select category.id AS catid, category.name AS catname, scategory.cparent AS    scparent, scategory.name AS scname
  from category
  left join scategory on category.id = scategory.cparent
  group by category.name'; // Select data from database
        $result = mysql_query($catmenu_sql); 
  
  while($rows = mysql_fetch_array($result)) { ?&gt;
  
  &lt;!-- Begin Category list --&gt;
  &lt;li class="menu"&gt;
      &lt;a href="category.php?id=&lt;?php echo $rows['catid']; ?&gt;" id="&lt;?php echo $rows['catid']; ?&gt;" class="menu"&gt;&lt;?php echo($rows['catname']); ?&gt;&lt;/a&gt;
  &lt;/li&gt;
  &lt;!-- End Category List --&gt;   
  
  &lt;?php 
      if (isset($_GET['id']) &amp;&amp; is_numeric($_GET['id'])) // get the 'id' variable from the URL and match it with scategory parent in database
      $id = $_GET['id'];
      $sid = $rows['scparent'];
      if ( $id == $sid ) {
  ?&gt;
  
  &lt;!-- Begin Sub Category List --&gt;    
  &lt;ul&gt;
  &lt;li class="menu"&gt;&lt;a href="scategory.php?id= &lt;?php echo $rows['catid']; ?&gt;" id=" &lt;?php echo $rows['catid'];?&gt;"class="smenu"&gt;&lt;?php echo $rows['scname']; ?&gt;&lt;/a&gt;
      &lt;/li&gt;
  &lt;/ul&gt;
  &lt;!-- End Sub category List --&gt;
  &lt;?php }} ?&gt;
  &lt;/ul&gt;'
  </code></pre>
  
  <p>Any help  will be appreciated. Thank you</p>