Professional Web Applications Themes

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

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 ...

Sponsored Links
  1. #1

    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


    Sponsored Links
    Phil Guest

  2. #2

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

    Oopps.. sorry wrong newsgroup.



    Phil Guest

  3. #3

    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/001020/celko1_1.jhtml;jsessionid=4APY0UCZ22UYCQSNDLPSKH0C JUNN2JVN?_requestid=51675

    Good luck.

    -- Bill

    "Phil Latio" <co.uk> wrote in message
    news:RZvwh.89252$news.easynews.com... 


    AlterEgo Guest

  4. #4

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

    On 2 Feb, 00:55, "Phil Latio" <co.uk> 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

    Captain Guest

  5. #5

    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 

    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





    Phil Guest

  6. #6

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

    Phil Latio wrote: 
    >
    > 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[/ref]

    I did notice that, but too late :-(

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


    Paul Guest

  7. #7

    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


    Phil Guest

Similar Threads

  1. Why does Dreamweaver display full path spec to datatables?
    By KJ Klosson in forum Coldfusion Database Access
    Replies: 1
    Last Post: November 17th, 04:24 PM
  2. [PHP] Getting the FULL path
    By Jason in forum PHP Development
    Replies: 2
    Last Post: October 2nd, 05:47 PM
  3. full path name
    By wes in forum Mac Programming
    Replies: 5
    Last Post: September 8th, 10:39 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139