-2

您好,我尝试进行类似我的查询:

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');

大批 (

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

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

)

我尝试为查看 itemID 的每个父项创建一个 foreach 并按父项显示每个项,但不是每次都重写父项的名称。谢谢

4

1 回答 1

0

也许嵌套 foreach(es)

 foreach ($array as $item) {
    foreach ($item as $parent) {
        foreach ($parent as $data) {
            echo $data;
        }
    }
 }
于 2013-04-27T15:20:39.060 回答