Table of Contents
设计树状结构货品分类状态,树状结构货品分类
怎设计树状结构数据表
提供一些用JAVA编程的典型项目名称,有详细说明就好
Home php教程 php手册 设计树状结构货品分类状态,树状结构货品分类

设计树状结构货品分类状态,树状结构货品分类

Jun 13, 2016 am 09:22 AM
header php Classification state structure design

设计树状结构货品分类状态,树状结构货品分类

1 php 2 header('Content-Type:text/html; charset=utf-8'); 3 $mp = array( 4 'name' => '手机', 'children' => array( 5 array('name' => '非智能机'), 6 array('name' => '智能机', 'children' =>array( 7 array('name' => '安卓机'), 8 array('name' => '苹果机'), 9 array('name' => 'WP机') 10 )) 11 ) 12 ); 13 14 $cp =array( 15 'name' => '电脑', 'children' => array( 16 array('name' => '电脑整机', 'children' => array( 17 array('name' => '笔记本'), 18 array('name' => '超极本'), 19 array('name' => '游戏本') 20 )), 21 array('name' => '电脑配件', 'children' => array( 22 array('name' => 'CPU'), 23 array('name' => '主板') 24 )) 25 ) 26 ); 27 28 $goodsCats = array($mp, $cp); 29 30 //递归遍历$goodsCat中的所有元素 31 function tree($goodsCats, $deep=0){ 32 //1:定义一个容器装所有的分类 33 static $tree = array(); 34 //2:定义一个变量来记录分类的级别 35 ++$deep; 36 foreach($goodsCats as $goodsCat){ 37 $treeCat = array('name' => $goodsCat['name']); //将分类名字存放到数组中 38 $treeCat['deep'] = $deep; //将分类级别也存放到数组中 39 $tree[] = $treeCat; //将每次循环的分类存放起来 40 //检查每个分类下是否有子分类,如果有,继续遍历 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

 

怎设计树状结构数据表

举个例子吧,我用的表结构是这样的,你可以参考下名称     类型    约束条件    说明
type_id   int   无重复   类别标识,主键
type_name   char(50) 不允许为空 类型名称,不允许重复
type_father int 不允许为空 该类别的父类别标识,如果是顶节点的话设定为某个唯一值
type_layer char(6) 限定3层,初始值为000000 类别的先序遍历,主要为减少检索数据库的次数  按照这样的表结构,我们来看看上面例子记录在表中的数据是怎样的:type_id type_name type_father type_layer
1 总类别 0 000000
2 类别1 1 010000
3 类别1.1 2 010100
4 类别1.2 2 010200
5 类别2 1 020000
6 类别2.1 5 020100
7 类别3 1 030000
8 类别3.1 7 030100
9 类别3.2 7 030200
10 类别1.1.1 3 010101
……  现在按type_layer的大小来检索一下:SELECT * FROM Type_table_2 ORDER BY type_layer列出记录集如下:type_id type_name type_father type_layer
1 总类别 0 000000
2 类别1 1 010000
3 类别1.1 2 010100
10 类别1.1.1 3 010101
4 类别1.2 2 010200
5 类别2 1 020000
6 ......余下全文>>
 

提供一些用JAVA编程的典型项目名称,有详细说明就好

1:chat项目
Chat项目通过完成一个模拟的在线聊天系统,主要锻炼大家对于TCP/IP、Socket编程、C/S模式的编程、线程的运用等方面的能力。
这个项目所涉及的知识点包括JavaSE、Socket、C/S、多线程等。

2:坦克单机版/图片版/网络版项目
这三个项目通过大家喜闻乐见的小游戏的形式来锻炼大家对于JavaSE综合运用的能力,并且能够初步运用面向对象的编程理念,锻炼初步的设计能力,并基本掌握多线程的编程。
这三个项目所涉及的知识点包括JavaSE、Socket、C/S、多线程、AWT、GUI、事件处理、Eclipse运用、Debug调试、属性文件的运用、图片的处理等。

3:设计模式版坦克大战
这个项目是上面坦克项目的替代者,在预习了上面项目之后,这个项目的重点在于培养大家对于设计模式的理解,对于设计模式,如果有一定的代码量,并且理解了面向对象的话,理解单个的设计模式是非常容易的,但是对于多个设计模式的综合运用,恐怕还需要综合练习,与此同时,对于多层架构,SSH框架等,如果想理解得更透彻,更底层,设计模式也是必不可少的。这个项目正式通过综合运用多个设计模式来达到理解模式,并且为后面的课程做好准备。
这个项目所涉及的知识点包括JavaSE、多线程、AWT、GUI、事件处理、Eclipse运用、Debug调试、属性文件的运用、Singleton模式、Factory系列模式、Strategy模式、Observer模式、ChainOfResponsibility模式、Composite模式以及设计模式的综合运用等。

4:BBS2006 / BBS2007项目
BBS的两个项目完成了一个具备完善前台展现以及后台管理的论坛系统,论坛系统的业务逻辑大家比较熟悉,是用来进行JavaWeb开发的极好的入门系统。但是由于其业务逻辑太简单,尚学堂目前的课程体系中已经用搜索项目来替代它。
这个项目所涉及的知识点包括JDBC、数据库、HTML、CSS、java script、AJAX、分页、树状结构的设计与展现、JSP、Servlet、Session等。

6: 企业搜索项目
在google和baidu上,一个简单的页面背后,抓取/索引/搜索/缓存等尖端技术在起着决定性的支撑性的作用,与此同时,随着企业知识库系统/知识管理系统/文档管理系统等大量应用,大量的企业非常需要应用搜索系统,这个项目通过开源的搜索引擎系列项目/蜘蛛程序等搭建一个高效的搜索系统,这个系统是完全可以应用在企业级项目之中的,同时,帮助同学们理解搜索引擎的原理,另外,也融合初步的用户管理/树状展现等知识点。
这个项目所涉及的知识点包括抓取、索引、搜索、缓存、JDBC、数据库、HTML、CSS、java script、AJAX、分页、树状结构的设计与展现、JSP、Servlet、Session等,并且详细讲解了搜索相关的开源系列软件(Lucene等),同时也详细介绍了搜索引擎的原理。

7:金尚在线商城项目
这个系统整合了商品展示、商品管理、商品类别管理、购物车、会员管理等功能,提供了简易的操作,丰富的功能和完善的权限管理,为用户提供了一个低成本、高效率的网上商城建设方案。这个项目在商品类别设计中采用了树状层次设计结构;在前台可以分类浏览所有商品详细信息,下订单购买商品,查看购物车状态以及购买用户的反馈信息;在系统后台可以管理会员、管理商品和商品类别......余下全文>>
 

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

7 PHP Functions I Regret I Didn't Know Before 7 PHP Functions I Regret I Didn't Know Before Nov 13, 2024 am 09:42 AM

If you are an experienced PHP developer, you might have the feeling that you’ve been there and done that already.You have developed a significant number of applications, debugged millions of lines of code, and tweaked a bunch of scripts to achieve op

How do you parse and process HTML/XML in PHP? How do you parse and process HTML/XML in PHP? Feb 07, 2025 am 11:57 AM

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

PHP Program to Count Vowels in a String PHP Program to Count Vowels in a String Feb 07, 2025 pm 12:12 PM

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? Apr 03, 2025 am 12:03 AM

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.

See all articles