title: Diplay items for category PHP and echo categories as link to each view
body: <p>Hello im learning so im sorry if this is a fool question. (also sorry about my bad english)</p>
  
  <p>Im trying to display the items from a particular category. </p>
  
  <p>In my Database, i have set my categories like this.</p>
  
  <p><img src="https://i.stack.imgur.com/IisMa.jpg" alt="Categories"></p>
  
  <p>And the Products or Items like this, </p>
  
  <p><img src="https://i.stack.imgur.com/w0VWe.jpg" alt="items"></p>
  
  <p>Im using this code to display tree categories.</p>
  
  <pre><code>function hasChild($parent_id)
    {
      $sql = "SELECT COUNT(*) as count FROM category WHERE parent_id = '" . $parent_id . "'";
      $qry = mysql_query($sql);
      $rs = mysql_fetch_array($qry);
      return $rs['count'];
    }
  
    function CategoryTree($list,$parent,$append)
    {
      $list = '&lt;li&gt;'.$parent['name'].'&lt;/li&gt;';
  
      if (hasChild($parent['id'])) // check if the id has a child
      {
        $append++;
        $list .= "&lt;ul class='child child".$append."'&gt;";
        $sql = "SELECT * FROM category WHERE parent_id = '" . $parent['id'] . "'";
        $qry = mysql_query($sql);
        $child = mysql_fetch_array($qry);
        do{
          $list .= CategoryTree($list,$child,$append);
        }while($child = mysql_fetch_array($qry));
        $list .= "&lt;/ul&gt;";
      }
      return $list;
    }
    function CategoryList()
    {
      $list = "";
  
      $sql = "SELECT * FROM category WHERE (parent_id = 0 OR parent_id IS NULL)";
      $qry = mysql_query($sql);
      $parent = mysql_fetch_array($qry);
      $mainlist = "&lt;ul class='parent'&gt;";
      do{
        $mainlist .= CategoryTree($list,$parent,$append = 0);
      }while($parent = mysql_fetch_array($qry));
      $list .= "&lt;/ul&gt;";
      return $mainlist;
    }
  </code></pre>
  
  <p>But i cant find a good way to convert the categories in links, so each time a users clic one category i will display the items for that category..</p>
  
  <p>What would be the best for that.</p>
  
  <p>If you can point me in the right direction, some tutorial, or something, would be really , really great.</p>