Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- What structure for multi level menu?
- Harris Kosmidhs
May 21, 2009, 7:40 am
rate this thread
I have a db table like this:
CREATE TABLE `categories` (
`id` int(11) NOT NULL auto_increment,
`description` varchar(300) collate utf8_unicode_ci NOT NULL,
`level` int(11) NOT NULL default '0',
`parent` int(11) NOT NULL,
`order` int(11) NOT NULL default '1',
`active` tinyint(4) NOT NULL default '1',
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
For example the following menu :
Sport Events --> Football --> Football event on 1-Jun-2009
| --> Football event on 12-Jun-2009
Music events --> Concert 1
will be coded as
id | description | level | parent
1 | Sport Events | 0 | 0
2 | Music events | 0 | 0
3 | Football | 1 | 1
4 | Football event on 1-Jun-2009 | 2 | 3
5 | Football event on 12-Jun-2009 | 2 | 4
6 | Volley | 1 | 1
7 | Concert 1 | 1 | 2
8 | Concert 2 | 1 | 2
How can I grab this in a table or something? I use CakePHP. I want to
cache this table in some structure, so as to use it in several parts of
my application. I don't want a single-level table like SELECT * from table..
Re: What structure for multi level menu?
Harris Kosmidhs wrote:
You can start with a SQL newsgroup to get your SQL working. After that,
it should be easy to build into an array or similar in PHP.
Remove the "x" from my email address
JDS Computer Training Corp.