Design tree structure goods classification status, tree structure goods Classification _php Tutorial

Source: Internet
Author: User
Tags knowledge base

Design tree structure goods classification status, tree structure goods classification


1 Php 2 Header(' content-type:text/html; Charset=utf-8 ' ); 3 $MP= Array ( 4' Name ' = ' phone ', ' children ' Array ( 5 Array(' name ' = ' = ' Non-smart machine '), 6 Array(' name ' = ' smart machine ', ' children ' = Array ( 7 Array(' name ' = ' Andro '), 8 Array(' name ' = ' mac '), 9 Array(' name ' = ' WP machine ' ) Ten )) One ) A ); - - $CP= Array ( the' Name ' = ' computer ', ' children ' = Array ( - Array(' name ' = ' computer machine ', ' children ' = Array ( - Array(' name ' = ' notebook '), - Array(' name ' = ' + ' super-Ben '), + Array(' name ' = = ' game Ben ' ) -)), + Array(' name ' = ' Computer accessories ', ' children ' = Array ( A Array(' name ' = ' + ' CPU '), at Array(' name ' = ' motherboard ' ) - )) - ) - ); - - $goodsCats= Array( $MP, $CP ); in - // recursively traverse all elements in the $goodscat to functionTree $goodsCats, $deep=0 ){ + // 1: Define a container to pack all the categories - Static $tree= Array (); the // 2: Define a variable to record the level of classification *++ $deep ; $ foreach( $goodsCats as $goodsCat ){ Panax Notoginseng $treeCat= Array(' name ' = = $goodsCat[' name ']); // to store the category name in an array - $treeCat[' deep '] = $deep; // to store the classification level in an array the $tree[] = $treeCat; // Store the classification of each cycle + //Check if there are sub-classifications under each category, and if so, continue traversing A if( isset( $goodsCat[' Children ' ])){ theTree $goodsCat[' Children '], $deep ); + } - } $ return $tree ; $ } - - $treeData= Tree ( $goodsCats ); the - foreach( $treeData as $catData ){ Wuyi Echo str_repeat('------',( $catData[' Deep ']-1)]. $catData[' name ']. "
" ; the} View Code


How to design a tree-like structure data table

For example, I use the table structure is this, you can refer to the following name type constraints description
type_id int no repeating category ID, primary key
Type_name Char (50) does not allow null type names and does not allow duplicates
Type_father int is not allowed to be empty for the parent class identifier, if the top node is set to a unique value
Type_layer Char (6) limited to 3 layers, initial value of 000000 categories of first-order traversal, mainly to reduce the number of databases retrieved according to such a table structure, we take a look at the above example recorded in the table data is how: 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
...... Now search by the size of the Type_layer: SELECT * from type_table_2 the ORDER by Type_layer lists the recordset 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 that are programmed in Java, as described in detail.

1:chat Project
Chat project through the completion of a simulated online chat system, the main training for the TCP/IP, socket programming, C/S mode programming, threading and other aspects of the ability to use.
This project involves the knowledge points include Javase, Socket, C/S, multithreading and so on.

2: Tank stand-alone/Photo/web-version Project
These three projects through popular small game form to exercise everybody to javase comprehensive use of ability, and can preliminary use object-oriented programming concept, exercise preliminary design ability, and basic master multi-threaded programming.
The knowledge points involved in these three projects include Javase, sockets, C/S, multithreading, AWT, GUI, event processing, Eclipse application, debug debugging, application of attribute files, image processing, and more.

3: Design mode version tank battle
This project is an alternative to the above tank project, after previewing the above project, the focus of this project is to develop the understanding of design patterns, for design patterns, if there is a certain amount of code, and understand the object-oriented, it is very easy to understand the individual design patterns, but for multiple design patterns of integrated use , I am afraid that there is a need for comprehensive practice, at the same time, for multi-layered architecture, SSH framework, if you want to understand more thoroughly, lower level, design patterns are essential. The project formally uses multiple design patterns to achieve an understanding model, and prepares for the subsequent course.
The knowledge points involved in this project include Javase, multithreading, AWT, GUI, event processing, Eclipse usage, debug debugging, application of attribute files, Singleton mode, Factory series mode, strategy mode, observer mode, chainofresponsibility mode, composite mode and the comprehensive application of design pattern.

4:bbs2006/bbs2007 Project
BBS's two projects completed a good front display and backstage management of the forum system, the business logic of the forum system are familiar to us, is used to carry out javaweb development of the excellent entry system. But because its business logic is too simple, the school's current curriculum system has been replaced with search items.
The 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 Project
On Google and Baidu, a simple page behind, Crawl/index/search/cache and other cutting-edge technology plays a decisive supporting role, at the same time, with the Enterprise Knowledge Base System/knowledge management System/document management system and other applications, a large number of enterprises need to apply the search system, This project through the open-source Search Engine series project/spider program to build an efficient search system, the system is fully applicable to enterprise-level projects, while helping students understand the principles of search engines, in addition, also fused to the initial user management/tree-like display and other knowledge points.
The knowledge points involved in this project include crawl, index, search, cache, JDBC, database, HTML, CSS, java Script, AJAX, pagination, tree structure design and presentation, JSP, Servlet, session, etc. The search-related open source series software (Lucene, etc.) is explained in detail, and the principle of search engine is also introduced in detail.

7: Golden Shang Online Mall project
This system integrates commodity display, commodity management, commodity category management, shopping cart, member management and other functions, provides simple operation, rich functions and perfect authority management, providing users with a low-cost, efficient online mall construction program. The project uses a tree-like hierarchy design structure in the product category design; In the front desk, you can sort through all product details, place orders to purchase items, view cart status and purchase feedback from users, manage members, manage goods and product categories in the background ... Remaining full text >>

http://www.bkjia.com/PHPjc/899961.html www.bkjia.com true http://www.bkjia.com/PHPjc/899961.html techarticle Design tree structure goods classification status, tree structure goods category 1? PHP 2 header (' content-type:text/html; Charset=utf-8 '); 3 $mp = array (4 ' name ' = ' phone ', ' C Hildren ' = 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.