-2

Hello i try to make something like my query:

result = mysql_query('SELECT subitems.ItemID, subitems.Parent, subitems.Data, items.ID FROM subitems INNER JOIN items ON items.ID = subitems.ItemID WHERE subitems.ItemID = \''. $item['ID'] .'\' GROUP BY subitems.Parent ASC, subitems.Data ASC');

Array (

[ItemID] => 1
    (
      [Parent] => 1
          (
              [Data] => 1
              [Data] => 2
              [Data] => 3
          )
    )

[ItemID] => 1
    (
      [Parent] => 2
          (
              [Data] => 1
              [Data] => 2
              [Data] => 3
          )
    )

)

i try to make a foreach for see each parent of itemID and display each items by parent, but not rewrite the name of parent everytime. thx

  • [What have you tried?](http://mattgemmell.com/2008/12/08/what-have-you-tried/) See [about Stack Overflow](http://stackoverflow.com/about). – John Conde Apr 27 '13 at 15:16

1 Answers1

0

Maybe nested foreach(es)

 foreach ($array as $item) {
    foreach ($item as $parent) {
        foreach ($parent as $data) {
            echo $data;
        }
    }
 }
seniorpreacher
  • 666
  • 2
  • 11
  • 31
  • here my query $result = mysql_query('SELECT subitems.ItemID, subitems.Parent, subitems.Data, items.ID FROM subitems INNER JOIN items ON items.ID = subitems.ItemID WHERE subitems.ItemID = \''. $item['ID'] .'\' GROUP BY subitems.Parent ASC, subitems.Data ASC'); – user2327112 Apr 27 '13 at 17:09
  • Hi, I found [this](http://stackoverflow.com/questions/3261228/convert-flat-array-to-the-multi-dimentional) – seniorpreacher Apr 28 '13 at 20:12
  • And also [this](http://www.slideshare.net/billkarwin/models-for-hierarchical-data) This is a long-long explanation, but probably you will find it helpful. – seniorpreacher Apr 28 '13 at 20:13