Designing tree structure Product Classification status and tree structure Product Classification _ PHP Tutorial

Source: Internet
Author: User
Design the product category status of the tree structure, and the product category of the tree structure. The product category status of the tree structure is designed. what is the product category of the tree structure? Php2header (Content-Type: texthtml; charsetutf-8); 3 $ mparray (4name mobile phone, childrenarray design tree structure Product Classification status, tree structure Product Classification

1 'Cell Phone ', 'Children' => array (5 array ('name' => 'non-smartphone '), 6 array ('name' => 'smartphone ', 'Children '=> array (7 array ('name' => 'Android'), 8 array ('name' => 'applog '), 9 array ('name' => 'WP macher') 10) 11) 12); 13 14 $ cp = array (15 'name' => 'PC ', 'Children '=> array (16 array ('name' => 'computer ID', 'Children' => array (17 array ('name' => 'notebooks '), 18 array ('name' => 'ultrabode'), 19 array ('name' => 'gamely') 20 )), 21 array ('name' => 'computer accessories ', 'Children' => array (22 array ('name' => 'CPU '), 23 array ('name' => 'mainboard ') 24) 25) 26); 27 28 $ goodsCats = array ($ mp, $ cp ); 29 30 // recursively traverse all elements in $ goodsCat 31 function tree ($ goodsCats, $ deep = 0) {32 // 1: define a container to hold all categories 33 static $ tree = array (); 34 // 2: define a variable to record classification levels 35 + $ deep; 36 foreach ($ goodsCats as $ goodsCat) {37 $ treeCat = array ('name' => $ goodsCat ['name']); // store the category name in the array 38 $ treeCat ['deep '] = $ deep; // store the category level in the array 39 $ tree [] = $ treeCat; // store the categories of each loop 40 // Check whether there are subcategories under each category. if yes, continue to traverse 41 if (isset ($ goodsCat ['Children ']) {42 tree ($ goodsCat ['Children '], $ deep); 43} 44} 45 return $ tree; 46} 47 48 $ treeData = tree ($ goodsCats ); 49 50 foreach ($ treeData as $ catData) {51 echo str_repeat ('------', ($ catData ['deep ']-1 )). $ catData ['name']."
"; 52}View Code


How to design a tree structure data table

For example, the table structure I use is as follows. you can refer to the description of Name Type constraints.
Type_id int no duplicate Category ID, primary key
Type_name char (50) cannot be empty or repeated
Type_father int cannot be null. if it is a top node, it is set to a unique value.
Type_layer char (6) is limited to three layers. The initial value is the first sequential traversal of the 000000 category, mainly to reduce the number of times the database is retrieved according to this table structure, let's take a look at the data recorded in the above example in the table: type_id type_name type_father type_layer
1. total Category 0 000000
2 Category 1 1 010000
3 Category 1.1 2 010100
4 Category 1.2 2 010200
5 Category 2 1 020000
6 Category 2.1 5 020100
7 Category 3 1 030000
8 Category 3.1 7 030100
9 Category 3.2 7 030200
10 Category 1.1.1 3 010101
...... Search BY the type_layer size: SELECT * FROM Type_table_2 order by type_layer lists the record sets as follows: type_id type_name type_father type_layer
1. total Category 0 000000
2 Category 1 1 010000
3 Category 1.1 2 010100
10 Category 1.1.1 3 010101
4 Category 1.2 2 010200
5 Category 2 1 020000
6 ...... remaining full text>
 

Provide some typical project names programmed in JAVA.

1: chat project
By completing a simulated online Chat system, the Chat project mainly exercises everyone's capabilities in TCP/IP, Socket programming, C/S mode programming, and thread application.
Knowledge points involved in this project include JavaSE, Socket, C/S, and multithreading.

2: tank stand-alone/Image/online project
These three projects train everyone's ability to use JavaSE in a comprehensive manner in the form of games that everyone enjoys. They can also use object-oriented programming concepts to train their preliminary design capabilities, and basically master the multi-thread programming.
Knowledge points involved in these three projects include JavaSE, Socket, C/S, multithreading, AWT, GUI, event processing, Eclipse application, Debug debugging, attribute file application, and image processing..

3: Design pattern version Tank Wars
This project is a replacement for the above tank project. after previewing the above project, the focus of this project is to cultivate everyone's understanding of the design model. if there is a certain amount of code for the design model, it is very easy to understand a single design mode if you understand the object-oriented architecture. However, you may need to perform comprehensive exercises for the comprehensive use of multiple design modes. at the same time, for multi-layer architecture, if you want to understand the SSH framework more thoroughly and at the underlying level, the design mode is also essential. This project officially uses multiple design modes to achieve the understanding mode, and prepares for the subsequent courses.
Knowledge points involved in this project include JavaSE, multithreading, AWT, GUI, event processing, Eclipse application, Debug debugging, attribute file application, Singleton mode, Factory Series Mode, Strategy mode, Observer mode, ChainOfResponsibility mode, Composite mode, and comprehensive application of the design mode.

4: BBS2006/BBS2007 project
Two BBS projects have completed a complete forum system with front-end presentation and background management. The business logic of the forum system is familiar to everyone and is an excellent entry system for Java web development. However, because its business logic is too simple, Shang Xuexiang's current curriculum system already uses search projects to replace it.
Knowledge points involved in this project include JDBC, database, HTML, CSS, java script, AJAX, paging, tree structure design and presentation, JSP, Servlet, Session, etc.

6: Enterprise Search Items
On google and baidu, cutting-edge technologies such as crawling, indexing, searching, and caching play a decisive role behind a simple page. at the same time, with a large number of applications such as enterprise knowledge base system, knowledge management system, and document management system, a large number of enterprises need to use search systems, this project builds an efficient search system through open-source search engine projects/spider programs. this system can be fully applied to enterprise-level projects. at the same time, help students understand the principles of search engines. In addition, it also integrates initial user management/tree presentation and other knowledge points.
Knowledge points involved in this project include crawling, indexing, search, caching, JDBC, database, HTML, CSS, java script, AJAX, paging, tree structure design and presentation, JSP, Servlet, Session, etc, the open-source software (Lucene) related to search is explained in detail, and the principles of search engines are also described in detail.

7: Jinshang online mall project
This system integrates functions such as product display, product management, product category management, shopping cart, and member management, providing simple operations, rich functions, and complete permission management, it provides users with a low-cost and efficient online mall construction solution. This project adopts a tree-level structure in the product category design. on the front-end, you can view all product details, place orders to purchase products, view the shopping cart status, and feedback from the users; you can manage members, products, and product categories in the background of the system ...... remaining full text>

Limit 1? Php 2 header ('content-Type: text/html; charset = utf-8 '); 3 $ mp = array (4 'name' = 'phone ', 'Children '= array...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.