易截截图软件、单文件、免安装、纯绿色、仅160KB

PHP无限分类的例子(包括数据库)转

其他常见的无限分类方法:
1,简单的通过递归查询加目录path字段的无限分类
缺点:查询数据库次数太多,不方便其他操作,比如删除节点。添加节点,移动节点
2,左右值无限分类,预排序二叉树
缺点:操作繁琐,数据库冗余,且添加删除修改都要进行左右值更新
本分类方法的优势:
1,数据库结构简单,只有 cid parentid name 三个字段,无任何冗余字段
2,不使用递归查询,所有操作只需一条sql语句
3,所有数据在读取一次数据库后,在数组内进行分析处理,节省数据库服务器资源
创建数据库以及表:
CREATE DATABASE `sortclass`DEFAULT CHARSET utf8;
CREATE TABLE IF NOT EXISTS `class` (
`cid` mediumint(8) unsigned NOT NULL auto_increment,
`pid` mediumint(8) unsigned NOT NULL,
`cname` varchar(50) NOT NULL,
PRIMARY KEY (`cid`),
KEY `pid` (`pid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
处理文件示例:
<?php
header("Content-type: text/html; charset=utf-8");
//连接数据库
$link = mysql_connect('localhost','root','eric') or die(mysql_error());
mysql_select_db('sortclass',$link);
//无限分类类库
class SortClass{
var $data = array();
var $child = array(-1=>array());
var $layer = array(-1=>-1);
var $parent = array();
var $link;
var $table;
function SortClass($link, $table){
$this->setNode(0, -1, '顶极节点');
$this->link = $link;
$this->table = $table;
$node = array();
$results = mysql_query('select * from '.$this->table.'',$this->link);
while($node = mysql_fetch_assoc($results)){
$this->setNode($node['cid'],$node['pid'],$node['cname']);
}
}
function setNode ($id, $parent, $value){
$parent = $parent?$parent:0;
$this->data[$id] = $value;
$this->child[$id] = array();
$this->child[$parent][] = $id;
$this->parent[$id] = $parent;
$this->layer[$id] = !isset($this->layer[$parent])? 0 : $this->layer[$parent] + 1;
}
function getList (&$tree, $root= 0){
foreach ($this->child[$root] as $key=>$id){
$tree[] = $id;
if ($this->child[$id]) $this->getList($tree, $id);
}
}
function getValue ($id){return $this->d


相关文档:

PHP批量删除技巧


首先要了解sql语句  
 
$SQL="delete from `PHP100` where id in (1,2,4)";
表单大概是:
 
<form action="" method="post">
<input name="ID_Dele[]" type="checkbox" id="ID_Dele[]" value="1"/>
<i ......

nginx+php cgi+mysql一键安装包更新版

[part1] http://download.csdn.net/source/2076258 
[part2] http://download.csdn.net/source/2076272
[part3] http://download.csdn.net/source/2076276
[part4] http://download.csdn.net/source/2076283
[part02-04] http://www.ytgps.com/Images/nginx.rar
本文件体积过大分4个包,php-cgi+mysql+nginx.7z ......

Php Test

<?php
/*
Version: v1.0
CopyRight Davis.z 2010
Creation Date 2010-02-25
----------------------- Table Script ------------------------
CREATE TABLE [dbo].[T_Employee](
[Name] [nvarchar](50) COLLATE Korean_90_CS_AS NOT NULL,
[Age] [nvarchar](5) COLLATE Korean_90_CI_AS NULL,
[ ......

PHP中设计模式的学习笔记

PHP中设计模式的学习笔记
设计模式(Design Pattern)是面向对象设计中反复出现的问题的解决方案,设计模式是一种比一般类的设计更加抽象的一种思想,
它往往涉及到多个类的定义和使用。
在PHP的开发过程中,经常使用到得设计模式包括:简单工厂模式、单元素模式、观察者模式、命令模式、策略模式以及MVC模式等。
 / ......

php 官网介绍

每个人都知道php.net,我们或早或晚的都会来到这里并不断的访问它。它是PHPer的主要参考网站,拥有大量有用的信息,但是这些信息却不是那么显而易见。
比较有用的官方PHP资源:
PHP官方函数手册下载: http://www.php.net/download-docs.php
 包含最新的chm中文版本,HTML版本
中文函数手册:http://www.php.net/m ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号