View Single Post
  #1 (permalink)  
Old April 20th, 2005, 05:23 AM
enchen enchen is offline
Registered User
 
Join Date: Apr 2005
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problems with displaying sub-cats...

Hi, I run a small News-script using mySQL/PHP and use the following function to call the category table and create a you-are-here link menu...

The category table consists of 4 fields
xid (cat id auto inc)
catalogname
description
parentid

function caturher($xid)
   {
      global $T_Catalog;
      $sql = "select catalogname,parentid from TableCatalog where xid='$xid'";
      $result = $this->select($sql);
      $cat = $result[0]["catalogname"];
      $parent = $result[0]["parentid"];
      if ($parent != "0") {
      $sql = "select xid,catalogname from $T_Catalog where xid='$parent'";
      $result2 = $this->select($sql);
      $txid = $result2[0]["xid"];
      $tcat = $result2[0]["catalogname"];
      $urher = "\n<a class=\"you_menu\" href=\"?choice=section&amp;xid=$txid\">$tcat</a> &raquo; ";
      }
      $urher .= $cat;
      return $urher;
   }

It works fine for 2 levels, e.g. home > news > archive, but if I add a subcat "test" under "archive" it displays home > archive > test instead of home > news > archive > test which off course would be the desired path to show...

I've tried various things like foreach and a while loop but I can`t seam to get this function to do what I want it to, namely to be able to print the path for "unlimited" number of sub categories.

Any help is VERY MUCH appreciated :(
Reply With Quote