Rich Bitch Posted October 31, 2010 Report Share Posted October 31, 2010 Mēģinu no datu bāzes izveidot daudz dimensiju masīvu: $array = array(); $sql = mysql_query("SELECT id, parent_id FROM table"); while($row = mysql_fetch_array($sql)) { $array[$row["parent_id"]] = $row["id"]; } Problēma tāda, ka ja masīvā tiek pievienots elements ar tādu pašu parent_id, tad iepriekšējais elements ar šo pašu parent_id tiek dzēsts un pievienots tikai jaunais. Vajadzētu, lai tam iepriekšējam (un iepriekšejiem) ierakstam jaunais ieraksts ar tādu pašu parent_id pievienotos klāt. Kur ir kļūda un ko vajadzētu mainīt, lai panāktu vēlamo rezultātu. Quote Link to comment Share on other sites More sharing options...
daGrevis Posted October 31, 2010 Report Share Posted October 31, 2010 $x['a']['b']; Quote Link to comment Share on other sites More sharing options...
101111 Posted October 31, 2010 Report Share Posted October 31, 2010 (edited) $array[$row["parent_id"]][] = $row["id"]; Edited October 31, 2010 by 101111 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.