我有一個表與categoryId,名稱和parentId。我想與父母和子女的樹建立一個HTML表狀結構建立類別 - 從MySQL表中的子類別的HTML列表
我的表看起來像這樣
------------------------------------------------------------------
id categoryId parentId categoryName SortSeq
------------------------------------------------------------------
1 438044691 NULL test 1
2 438044692 438044691 test item one 2
3 438044693 438044691 test item two 3
1 438044701 NULL testOne 4
2 438044702 438044701 testOne item one 5
3 438044703 438044701 testOne item two 6
1 438044709 NULL testTwo 7
2 438044710 438044709 testTwo item one 8
3 438044711 438044709 testTwo item two 9
結構可以有子子類別項目爲好。但在這個例子中它只是一個。
如果您認爲問題不完整,我將非常樂意爲您提供更多信息。
非常感謝。
的可能重複[遞歸類別與單個查詢?](http://stackoverflow.com/問題/ 3116330 /帶單一查詢的遞歸類別) – Gordon 2010-06-29 13:46:54
您能修改表格結構,添加新列等嗎? – Sonny 2010-06-29 19:59:45