Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP Databases
|
PHP Databases Using PHP in conjunction with databases. PHP questions not specific to databases should be directed to one of the other PHP forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 20th, 2005, 05:23 AM
Registered User
 
Join Date: Apr 2005
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 :(





Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems Displaying an image retrieved from SQL Se jazzcatone ASP.NET 1.x and 2.0 Application Design 2 September 3rd, 2005 09:53 AM
problems displaying data p2ptolu PHP Databases 2 May 12th, 2005 01:12 AM
validate.asp problems and logon.asp problems p2ptolu Classic ASP Databases 0 February 16th, 2005 02:34 PM
Problems displaying images via a variable nancy Classic ASP Basics 2 June 2nd, 2004 02:17 PM
Problems displaying web pages using IIS kathryne Classic ASP Professional 1 November 14th, 2003 12:48 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.