phpbar.de logo

Mailinglisten-Archive

[php] MySQL Query -- Multidimensionales Array ?!

[php] MySQL Query -- Multidimensionales Array ?!

ESV - Marco Schierhorn m.schierhorn at esv-group.de
Sam Feb 5 21:08:53 CET 2005


Hi folks,

 

i´ve a problem with a MySQL Query.

 

This is the table :

 

CREATE TABLE `kategorie` (

  `kategorie_pk_id` int(11) NOT NULL auto_increment,

  `kategorie_upper_id` int(11) default NULL,

  `kategorie_name` varchar(100) NOT NULL default '',

  `kategorie_erstellung` date NOT NULL default '0000-00-00',

  PRIMARY KEY  (`kategorie_pk_id`),

  KEY `IX_Relationship58` (`kategorie_upper_id`),

  CONSTRAINT `0_196` FOREIGN KEY (`kategorie_upper_id`) REFERENCES
`kategorie` (`kategorie_pk_id`)

) TYPE=Inn

 

 

These are some examples of the table data :

 

kategorie_pk_id   kategorie_upper_id      kategorie_name

 

1                 null                                   Zeitschriften |
Magazine

2                 null                                   Tageszeitungen

3                 null                                   Geld und Finanzen

4                 null                                   Punkte- Sammel
System

5                 null                                   Telekommunikation |
Handy

6                 null                                   Internet Services

7                 null                                   TV Services

8                 null                                   Strom

9                 null                                   Versandhandel

10                null                                  Einzelhandel

11                null                                  Hotels

12                null                                  Sonstiges

13                1                          Politik & Wirtschaft

14                1                          Auto & Motorrad

 

( We don´t need the field kategorie_erstellung for my problem )

 

I want to create a menu in PHP which shows the top points ( the points where

kategorie_upper_id is null ) and when you click on one point it should print
the points

below.

Example if you click Zeitschriften | Magazine it should show Politik &
Wirtschaft and

Auto & Motorrad

 

A Menu like this :

 

- Zeitschriften | Magazine

- Tageszeitungen

- Geld und Finanzen

- Punkte- Sammel System

- Telekommunikation | Handy

... ....

When you click on Zeitschriften | Magazine it should be like this :

- Zeitschriften | Magazine

  -  Politik & Wirtschaft 

  -  Auto & Motorrad

- Tageszeitungen

- Geld und Finanzen

- Punkte- Sammel System

- Telekommunikation | Handy

 

But the problem is that the sub-points can have another sublevel as well.

And so on. 

So there could be 3,4,5....n   sublevel.

Can i realize this with a mysql query and store the variables in an
multidimensional array ?!

 

Cheers 

 

Marco

 

Marco Schierhorn

 

ESV Media GmbH 

Meerbuscher Str. 64-78 | 40670 Meerbusch

Tel.          +49 (0)2159 / 815 98 42 | Fax. +49 (0)2159 / 9297-931

Mobil :    +49 (0) 173 / 99 37 000

 <BLOCKED::http://www.esv-group.de/> www.esv-group.de | info at esv-group.de
<BLOCKED::mailto:info at esv-group.de> 

 


php::bar PHP Wiki   -   Listenarchive