hierarchical

PHP Multidimensional array to unordered list, building up url path

耗尽温柔 提交于 2019-12-04 05:28:37
I have a multidimensional array in PHP produced by the great examples of icio and ftrotter (I am use ftrotterrs array in arrays variant): Turn database result into array I have made this into a unordered list width this method: public function outputCategories($categories, $startingLevel = 0) { echo "<ul>\n"; foreach ($categories as $key => $category) { if (count($category['children']) > 0) { echo "<li>{$category['menu_nl']}\n"; $this->outputCategories($category['children'], $link , $start, $startingLevel+1); echo "</li>\n"; } else { echo "<li>{$category['menu_nl']}</li>\n"; } } echo "</ul>\n"

how to get the hierarchical menu from mysql

爱⌒轻易说出口 提交于 2019-12-03 20:41:37
I have a table having hierarchical menus like "id" "parent_id" "name" 1 0 menu 2 1 item1 3 2 item1_1 4 1 item2 5 4 item2_1 ... ... and I have 100s of menu items here. In order to get all items in an array I have to write a recursive function like this getmenu function(parent_id = 1) { $items = mysql_query("SELECT id FROM table WHERE parent_id = " + parent_id); while ($item = msyql_Fetch_assoc($items)) { ...here I put them in array and call recursive function again to get sub items... getmenu($item['id']); } } but this executes 100s of queries. Is this the best way to do this, to get

Mysql sorting Hierarchical data

荒凉一梦 提交于 2019-12-03 20:18:16
I have a question and working last week with this and couldnt solve yet.. I can query submenus with join but i cant order it. I have a table like this | id | name | parent | order | |-------------------------------------------| | 1 | menu1 | 0 | 1 | | 2 | submenu1 | 1 | 2 | | 3 | submenu2 | 1 | 1 | | 4 | subsubmenu | 2 | 1 | | 5 | subsubsubmenu:) | 4 | 1 | | 6 | menu2 | 0 | 3 | | 7 | menu3 | 0 | 2 | |-------------------------------------------| I wanna get something like this. | - menu1 | - submenu2 | - submenu1 | - subsubmenu | - subsubsubmenu:) | - menu3 | - menu2 Can anybody give me an idea

Hierarchical Query CONNECT BY Oracle

戏子无情 提交于 2019-12-02 20:15:44
问题 I am trying to implement the Connect By query in oracle. Trying to understand how it works. So I have a simple table which looks likes: empno ename mno 1 KS null 2 AB 2 3 BC 1 4 TR 3 5 QE 2 6 PL 3 7 LK 6 The Query SELECT empno, ename, mno FROM test START WITH ename = 'LK' CONNECT BY PRIOR empno = mno; So when the name is LK I should get the following parent/child rows LK>PL>BC>KS. The SQLFIDDLE But I am not getting the correct results. What I am doing wrong ? 回答1: No, you should not. LK's

Sql question: Getting Parent rows followed by child rows

[亡魂溺海] 提交于 2019-12-02 19:23:51
问题 id parent_id 1 0 2 0 3 2 4 0 5 1 6 0 I need a query that will return parent rows (parent_id=0) followed by its child rows first parent all children of first parent second parent all children of second parent third parent fourth parent Expected result: ordered by id id parent_id 1 0 (first parent) 5 1 (all children of first parent) 2 0 second parent 3 2 (all children of second parent) 4 0 third parent 6 0 fourth parent I can use union of parents followed by all childs But that gives me parents

R is not taking the parameter hgap in layout_with_sugiyama

眉间皱痕 提交于 2019-12-02 12:34:57
问题 I'm working on R on a graph and I'd like to have a hierarchical plot, based on the values in the vector S (a value for each node). lay2 <- layout_with_sugiyama(grafo, attributes="all", layers = S, hgap=10, vgap=10) plot(lay2$extd_graph, vertex.label.cex=0.5) However, the paramaters hgap e vgap are not taken and the graph is really confused (even because I've got 162 nodes). I'm doing something wrong or there is another way in which I can do a hierarchical graph? 回答1: I believe that layout

R is not taking the parameter hgap in layout_with_sugiyama

妖精的绣舞 提交于 2019-12-02 04:30:31
I'm working on R on a graph and I'd like to have a hierarchical plot, based on the values in the vector S (a value for each node). lay2 <- layout_with_sugiyama(grafo, attributes="all", layers = S, hgap=10, vgap=10) plot(lay2$extd_graph, vertex.label.cex=0.5) However, the paramaters hgap e vgap are not taken and the graph is really confused (even because I've got 162 nodes). I'm doing something wrong or there is another way in which I can do a hierarchical graph? I believe that layout_with_sugiyama is working just fine, but you may be misinterpreting the output. Since you do not provide any

Getting root parent

与世无争的帅哥 提交于 2019-12-01 06:17:56
+--------+---------+-----------+ | id | title | parent_id | +--------+---------+-----------+ | 1 | Lvl-1 | null | +--------+---------+-----------+ | 2 | Lvl-2 | null | +--------+---------+-----------+ | 3 | Lvl-11 | 1 | +--------+---------+-----------+ | 4 | Lvl-12 | 1 | +--------+---------+-----------+ | 5 | Lvl-121 | 4 | +--------+---------+-----------+ How do i actualy get root parent for each row For example, row with id 5 have parent with id 4 and id 4 have parent with id 1 , so root id for id 5 is id 1 I dont have any idea on how to do it and is there a way to solve this by using only 1

Out of memory error while using clusterdata in MATLAB

感情迁移 提交于 2019-11-30 09:59:33
I am trying to cluster a Matrix (size: 20057x2).: T = clusterdata(X,cutoff); but I get this error: ??? Error using ==> pdistmex Out of memory. Type HELP MEMORY for your options. Error in ==> pdist at 211 Y = pdistmex(X',dist,additionalArg); Error in ==> linkage at 139 Z = linkagemex(Y,method,pdistArg); Error in ==> clusterdata at 88 Z = linkage(X,linkageargs{1},pdistargs); Error in ==> kmeansTest at 2 T = clusterdata(X,1); can someone help me. I have 4GB of ram, but think that the problem is from somewhere else.. As mentioned by others, hierarchical clustering needs to calculate the pairwise

Out of memory error while using clusterdata in MATLAB

浪尽此生 提交于 2019-11-29 14:50:46
问题 I am trying to cluster a Matrix (size: 20057x2).: T = clusterdata(X,cutoff); but I get this error: ??? Error using ==> pdistmex Out of memory. Type HELP MEMORY for your options. Error in ==> pdist at 211 Y = pdistmex(X',dist,additionalArg); Error in ==> linkage at 139 Z = linkagemex(Y,method,pdistArg); Error in ==> clusterdata at 88 Z = linkage(X,linkageargs{1},pdistargs); Error in ==> kmeansTest at 2 T = clusterdata(X,1); can someone help me. I have 4GB of ram, but think that the problem is