I have sub-categories but want to display full category path

This is a discussion on I have sub-categories but want to display full category path within the MySQL Database forums, part of the Database Forums category; Let's say I have a simple web application running with just two MySQL tables. The tables structure is as ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-02-2007
Phil Latio
 
Posts: n/a
Default I have sub-categories but want to display full category path

Let's say I have a simple web application running with just two MySQL
tables. The tables structure is as follows:

Table: category
category_id (PK)
category_name
parent_category (FK) //references category_id in this table

Table: link
link_id (PK)
link_name
link_description
category_id (FK) //references category_id in category table

Here is the data in the category table
1, England, 0
2, West Yorkshire, 1
3, Batley, 2
4, Leeds, 2
5, Bradford, 2

As you can see Batley, Leeds and Bradford are sub-categories of West
Yorkshire which itself is a sub-category of England.

What I want to display when I am browsing through sub-categories of links is
not only the name of that sub-category but it's category's parents, grand
parents and so on like the below example.

UK >> West Yorkshire >> Batley

I see this on a lot of directory sites but none of my PHP books cover how
this is done. Must be quite simple so can someone please point me in the
right direction. Hope I've explained it well enough, haven't a clue what
this process is called.

Cheers

Phil


Reply With Quote
  #2 (permalink)  
Old 02-02-2007
Phil Latio
 
Posts: n/a
Default Re: I have sub-categories but want to display full category path

Oopps.. sorry wrong newsgroup.



Reply With Quote
  #3 (permalink)  
Old 02-02-2007
AlterEgo
 
Posts: n/a
Default Re: I have sub-categories but want to display full category path

Phil,

Not for the faint of heart, but you can find Celko's adjacency list model in
the link below. It might work for you.

http://www.intelligententerprise.com...equestid=51675

Good luck.

-- Bill

"Phil Latio" <phil.latio@f-in-stupid.co.uk> wrote in message
news:RZvwh.89252$5l2.73290@fe02.news.easynews.com. ..
> Let's say I have a simple web application running with just two MySQL
> tables. The tables structure is as follows:
>
> Table: category
> category_id (PK)
> category_name
> parent_category (FK) //references category_id in this table
>
> Table: link
> link_id (PK)
> link_name
> link_description
> category_id (FK) //references category_id in category table
>
> Here is the data in the category table
> 1, England, 0
> 2, West Yorkshire, 1
> 3, Batley, 2
> 4, Leeds, 2
> 5, Bradford, 2
>
> As you can see Batley, Leeds and Bradford are sub-categories of West
> Yorkshire which itself is a sub-category of England.
>
> What I want to display when I am browsing through sub-categories of links
> is not only the name of that sub-category but it's category's parents,
> grand parents and so on like the below example.
>
> UK >> West Yorkshire >> Batley
>
> I see this on a lot of directory sites but none of my PHP books cover how
> this is done. Must be quite simple so can someone please point me in the
> right direction. Hope I've explained it well enough, haven't a clue what
> this process is called.
>
> Cheers
>
> Phil
>
>



Reply With Quote
  #4 (permalink)  
Old 02-02-2007
Captain Paralytic
 
Posts: n/a
Default Re: I have sub-categories but want to display full category path

On 2 Feb, 00:55, "Phil Latio" <phil.la...@f-in-stupid.co.uk> wrote:
> Let's say I have a simple web application running with just two MySQL
> tables. The tables structure is as follows:
>
> Table: category
> category_id (PK)
> category_name
> parent_category (FK) //references category_id in this table
>
> Table: link
> link_id (PK)
> link_name
> link_description
> category_id (FK) //references category_id in category table
>
> Here is the data in the category table
> 1, England, 0
> 2, West Yorkshire, 1
> 3, Batley, 2
> 4, Leeds, 2
> 5, Bradford, 2
>
> As you can see Batley, Leeds and Bradford are sub-categories of West
> Yorkshire which itself is a sub-category of England.
>
> What I want to display when I am browsing through sub-categories of links is
> not only the name of that sub-category but it's category's parents, grand
> parents and so on like the below example.
>
> UK >> West Yorkshire >> Batley
>
> I see this on a lot of directory sites but none of my PHP books cover how
> this is done. Must be quite simple so can someone please point me in the
> right direction. Hope I've explained it well enough, haven't a clue what
> this process is called.
>
> Cheers
>
> Phil


Please DO NOT multi-post. Cross post if you must but DO NOT multi-post

See http://www.blakjak.demon.co.uk/mul_crss.htm

Reply With Quote
  #5 (permalink)  
Old 02-02-2007
Phil Latio
 
Posts: n/a
Default Re: I have sub-categories but want to display full category path

> Please DO NOT multi-post. Cross post if you must but DO NOT multi-post
>
> See http://www.blakjak.demon.co.uk/mul_crss.htm


If you wish to check my second post which was sent a minute after the first,
you would have read that the original message was posted in the wrong group.
However as a reference should I err again, I am seriously interested to know
what I am expected to do?

I eagerly await your reply.

Cheers

Phil





Reply With Quote
  #6 (permalink)  
Old 02-03-2007
Paul Lautman
 
Posts: n/a
Default Re: I have sub-categories but want to display full category path

Phil Latio wrote:
>> Please DO NOT multi-post. Cross post if you must but DO NOT
>> multi-post See http://www.blakjak.demon.co.uk/mul_crss.htm

>
> If you wish to check my second post which was sent a minute after the
> first, you would have read that the original message was posted in
> the wrong group. However as a reference should I err again, I am
> seriously interested to know what I am expected to do?
>
> I eagerly await your reply.
>
> Cheers
>
> Phil


I did notice that, but too late :-(

However, bearing in mind the subject matter, this was actually the more on
topic group!


Reply With Quote
  #7 (permalink)  
Old 02-04-2007
Phil Latio
 
Posts: n/a
Default Re: I have sub-categories but want to display full category path

> I did notice that, but too late :-(

Not to worry. Just for anyone who might be interested, I posted a solution
in comp.lang.php.

Cheers

Phil


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 09:19 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0