MySQL Query -- Multidimensionale Arrays ?!

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • MySQL Query -- Multidimensionale Arrays ?!

    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

  • #2
    Hello,

    For solving your problem the keyword(s) "nested sets" should be very interesting and useful.

    In my bookmarks I've got several good links describing those, but only in german language:
    http://www.traum-projekt.com/forum/s...198#post443198
    http://www.develnet.org/36.html

    btw: you recognized this is a german speaking board, do you?.

    EDIT: Ich seh' grad, dass du aus Düsseldorf kommst, dann past das ja auch mit den deutschsprachigen Links.
    Zuletzt geändert von Indigo; 05.02.2005, 21:58.

    Kommentar


    • #3
      du kannst deine Menü rekursiv auslesen. Ich habe eine Klasse für MS-SQL geschrieben, aber du kannst die Funktionsweise dir trotzdem mal anschauen. Suche nach id parentid. Oder von anderen User, dann suche nach menü_menü (glaube ich)

      Kommentar

      Lädt...
      X