廣告招牌設計巧思運用,靈活搭配字型
燈光、安裝位置,幫您高調搶商機
油漆工程居住高品質的隔音門,無聲靜悄悄
引領業界,專營各式門窗,提供免費到府丈量

首頁  •  j2h 論壇 • 程式設計討論     • 

[php] mysql Tree Menu

房東:阿凱
發表時間:2011-08-31



Tree Menu



 


I have created a tree menu. This is working properly but when i click into a subcategory that subcategory page is not display. How can i add a page link into a subcategory.



My sql database structure is :



DROP TABLE IF EXISTS `category`;

CREATE TABLE IF NOT EXISTS `category` (

`rowid` bigint(20) NOT NULL AUTO_INCREMENT,

`category_id` bigint(20) NOT NULL,

`category_name` varchar(100) NOT NULL,

`language` char(2) NOT NULL DEFAULT 'EN' COMMENT 'english or french',

`parent_id` bigint(20) NOT NULL DEFAULT '0',

`level` int(11) NOT NULL DEFAULT '0',

PRIMARY KEY (`rowid`)

) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=56 ;



--

-- Dumping data for table `category`

--



INSERT INTO `category` (`rowid`, `category_id`, `category_name`, `language`, `parent_id`, `level`) VALUES

(1, 1, 'Information Technology', 'EN', 0, 0),

(2, 2, 'Graphic Design', 'EN', 0, 0),

(3, 3, 'Business Consulting', 'EN', 0, 0),

(4, 4, 'Administrative Support', 'EN', 0, 0),

(5, 5, 'Other Services', 'EN', 0, 0),

(6, 6, 'Informatique', 'Fr', 0, 0),

(7, 7, 'Conception Graphique ', 'Fr', 0, 0),

(8, 8, 'Conseil en Affaires', 'Fr', 0, 0),

(9, 9, 'Assistance Administrative ', 'Fr', 0, 0),

(10, 10, 'Autres Services ', 'Fr', 0, 0),

(11, 11, 'Web Design', 'EN', 1, 1),

(12, 12, 'Application Design', 'EN', 1, 1),

(13, 13, 'Database Development', 'EN', 1, 1),

(14, 14, 'EXCEL (macros, reports, etc...)', 'EN', 1, 1),

(15, 15, 'Apple Programming', 'EN', 1, 1),

(16, 16, 'Other IT', 'EN', 1, 1),

(17, 17, 'Graphic Design', 'EN', 2, 1),

(18, 18, 'Photo, Video', 'EN', 2, 1),

(19, 19, 'Logos Design', 'EN', 2, 1),

(20, 20, 'Signage and Advertising Design', 'EN', 2, 1),

(21, 21, 'Business Cards Design', 'EN', 2, 1),

(22, 22, 'Other', 'EN', 2, 1),

(23, 23, 'Finance', 'EN', 3, 1),

(24, 24, 'Sales and Marketing ', 'EN', 3, 1),

(25, 25, 'Accounting', 'EN', 3, 1),

(26, 26, '6 Sigma', 'EN', 3, 1),

(27, 27, 'Other', 'EN', 3, 1),

(28, 27, 'Personal Assistant', 'EN', 4, 1),

(29, 28, 'Translations', 'EN', 4, 1),

(30, 29, 'Word, PowerPoint, etc...', 'EN', 4, 1),

(31, 31, 'Other', 'EN', 4, 1),

(32, 32, 'Other', 'EN', 5, 1),

(33, 33, 'Conception de Sites Web ', 'Fr', 6, 1),

(34, 34, 'Conception d''Applications', 'Fr', 6, 1),

(35, 35, 'Développement de base de données ', 'Fr', 6, 1),

(36, 36, 'EXCEL (macros, rapports, etc...) ', 'Fr', 6, 1),

(37, 37, 'Programmation Apple ', 'Fr', 6, 1),

(38, 38, 'Autre', 'Fr', 6, 1),

(39, 39, 'Infographie', 'Fr', 7, 1),

(40, 40, 'Photo, Video', 'Fr', 7, 1),

(41, 41, 'Logos', 'Fr', 7, 1),

(42, 42, 'Enseignes Publicitaires ', 'Fr', 7, 1),

(43, 43, 'Cartes de visite', 'Fr', 7, 1),

(44, 44, 'Autre', 'Fr', 7, 1),

(45, 45, 'Comptabilité', 'Fr', 8, 1),

(46, 46, '6 Sigma', 'Fr', 8, 1),

(47, 47, 'Finance', 'Fr', 8, 1),

(48, 48, 'Marketing et Ventes', 'Fr', 8, 1),

(49, 49, 'Autre', 'Fr', 8, 1),

(50, 50, 'Compilation de documents (Word, PowerPoint...)', 'Fr', 9, 1),

(51, 51, 'Saisie de données ', 'Fr', 9, 1),

(52, 52, 'Traductions', 'Fr', 9, 1),

(53, 53, 'Secrétariat ', 'Fr', 9, 1),

(54, 54, 'Autre', 'Fr', 9, 1),

(55, 55, 'Autre', 'Fr', 10, 1);





And my code is :





PHP Syntax (Toggle Plain Text)



  1. <link rel="stylesheet" href="jquery.treeview.css" />
  2. <script type="text/javascript" src="jquery.min.js"></script>
  3. <script src="jquery.cookie.js" type="text/javascript"></script>
  4. <script src="jquery.treeview.js" type="text/javascript"></script>
  5. <script type="text/javascript" src="demo.js"></script>
  6. <?php
  7. include('dbconnect.php');
  8.  
  9. function generate_menu($link)
  10. {
  11. $sql="SELECT `rowid`, `category_id`, `category_name`, `language`, `parent_id`, `level` FROM `category` where `parent_id`='0'";
  12. $result=mysql_query($sql,$link);
  13. if(mysql_num_rows($result)>0)
  14. {
  15. echo"<ul id='browser' class='filetree'>";
  16. while($row=mysql_fetch_array($result))
  17. {
  18. echo"<li class='closed'><a href='#'>$row[2]</a>";
  19. generate_submenu($row[1],$link);
  20. echo"</li>";
  21. }
  22. echo"</ul>";
  23. }
  24. }
  25. function generate_submenu($category_id,$link)
  26. {
  27. $sql="SELECT `rowid`, `category_id`, `category_name`, `language`, `parent_id`, `level` FROM `category` where `parent_id`='$category_id'";
  28. $result=mysql_query($sql,$link);
  29. if(mysql_num_rows($result)>0)
  30. {
  31. echo"<ul>";
  32. while($row=mysql_fetch_array($result))
  33. {
  34. echo"<li><a href='#'>$row[2]</a></li>";
  35. }
  36. echo"</ul>";
  37. }
  38. }
  39. generate_menu($link);
  40. ?>
  41.  
  42. <!-- <ul id="browser" class="filetree">
  43. <li><span class="folder">Folder 1</span>
  44. <ul>
  45. <li><span class="file">Item 1.1</span></li>
  46. </ul>
  47. </li>
  48. <li><span class="folder">Folder 2</span>
  49. <ul>
  50. <li><span class="folder">Subfolder 2.1</span>
  51. <ul id="folder21">
  52. <li><span class="file">File 2.1.1</span></li>
  53. <li><span class="file">File 2.1.2</span></li>
  54. </ul>
  55. </li>
  56. <li><span class="file">File 2.2</span></li>
  57. </ul>
  58. </li>
  59. <li class="closed"><span class="folder">Folder 3 (closed at start)</span>
  60. <ul>
  61. <li><span class="file">File 3.1</span></li>
  62. </ul>
  63. </li>
  64. <li><span class="file">File 4</span></li>
  65. </ul>-->








Please someone help me on that.





  • 贊助網站       

    廣利不動產-板橋在地生根最實在--新板特區指名度最高、值得您信賴的好房仲
    完整房訊,房屋、店面熱門精選物件,廣利不動產 優質仲介,房屋租賃、買賣資訊透明,交易真安心!
    廣利不動產-新板特區指名度最高、值得您信賴的好房仲
    您的托付,廣利用心為您服務



  •  共 0 人回應

    姓名:
    佈告內容:
    其他選項: