3.Program control------------------------------------------------ -------------- This step is the most complicated and laborious to implement the unlimited classification function. First, let’s look at the steps that the program needs to complete: 1) Create a category and upload it; 2) Create an information upload; 3 ) Clearly display each category and the relationship between them; 4) Process the query function; 5) How to handle the editing and deletion functions; The most difficult of these five steps is the fifth step, because editing and deleting categories involves Let’s get to the specific question. Below I will describe the program control of PHP one by one: 1) Create category upload. Before introducing this function, let’s introduce the explode() function. This is a string processing function, used to decompose strings. Specific usage, for example: decompose the numbers in "0:1:2:3:4" $val=0:1:2:3:4; $rid=explode(":",$val); after explode( ) function processing, all the numbers in $val are decomposed into the $rid array. When you want to quote, just print: echo $rid[0],$rid[1],$rid[2]..."; The.explode() function plays a very important role in the entire classification process, so now we will introduce the program control of non-current classification. We can assume that there is a total classification of 0, and all classifications are its descendants. Now let’s establish the third classification. A classification system, let’s take a look at its storage form in the database: id | uid | type | rout_id | rout_char 1 | 0 | system | 0:1 | The system is then divided into Linux: id | uid | type | rout_id | rout_char 2 | 1 | Linux| 0:1:2 | System: Linux The above is the form of database storage. Now let’s complete the php code. This is very similar to the forum code. All we have to do is put the category id into uid, and the uid of the parent category is 0. Let’s take a look at the code: ..... ..... //设置默认页 if (empty($func)) $func==showtype; //设置父分类的 uid if (empty($uid)) $uid=0; //数据库存储************************************************ if ($func==save): $fields = ""; $values = ""; if ($id!="") { $fields .= ",id"; $values.=",$id"; } if ($uid!="") { $fields .= ",uid"; $values.=",$uid"; } if ($type!="") { $fields .= ",type"; $values.=",$type"; } if ($route_id=="") { //取得父分类的 route_id if ($uid!=0) { $result = mysqlquery("select * from type where id=$uid"); $route_id=mysql_result($result,0,"route_id"); } else { $routr_id=0; } $fields .= ",route_id"; //形成自己的 route_id $route_id="$route_id:$id"; $values.=",$route_id"; } //形成自己的 route_char if ($route_char!="") { $fields .= ",route_char"; $route_char="$route_char:$type"; $values.=",$route_char"; } else { $fields .= ",route_char"; $route_char=$type; $values.=",$route_char"; } $fields = substr($fields,1,strlen($fields)-1); $values = substr($values,1,strlen($values)-1); $result = mysqlquery("insert into type ($fields) values ($values)"); ... endif; /* end save */ //分类上传************************************************ if ($func==createtype): //取得自己的 id $result = mysqlquery("select * from type order by id desc"); $num=mysql_numrows($result); if (!empty($num)) { $cat = mysql_result($result,0,"id"); } else { $cat=0; } //判断分类的状态 if ($uid != 0) { $result=mysql_query("select * from type where id=$uid"); $type=mysql_result($result,0,"type"); $route_char=mysql_result($result,0,"route_char"); } else { $type=父分类; } echo ""; endif; /* end createtype */ //显示分类************************************************ if ($func==showtype): echo ""; //判断分类的状态 if ($uid!=0) { $result=mysql_query("select * from type where id=$uid"); $type=mysql_result($result,0,"type"); } else { $type=父分类; } echo "创建分类"; echo "$type"; $result=mysql_query("select * from type where uid=$uid"); $num=mysql_numrows($result); if (!empty($num)) { for ($i=0;$i