Unlimited classification implemented by php and mysql | relationship between tree display classification
- // $ Count indicates the classification level
- Sort_list ($ str, $ fatherid, $ count)
- {
- $ Rs = $ this-> SQL-> re_datas ("select * from sort where father_id = fatherid ");
- $ Num = $ this-> SQL-> SQL _numrows ();
- $ I = 0;
- $ N = 1;
- While (isset ($ rs [$ I])
- {
- $ Name = "";
- For ($ n = 1; $ n <$ count; $ n ++)
- {
- $ Name. = "│ ";
- }
- If ($ I + 1 = $ num)
- {
- $ Name. = "example-". $ rs [$ I] [name];
- }
- Else
- {
- $ Name. = "example-". $ rs [$ I] [name];
- }
- If ($ rs [$ I] [isdir])
- {
- $ Str. = "". $ name ."";
- }
- Else
- {
- $ Str. = $ name ";
- }
- $ Temp = $ count + 1;
- $ Str = $ this-> sort_list ($ str, $ rs [$ I] [id], $ temp );
- $ I ++;
- }
- Return $ str;
- }
- ?>
-
Where $ this-> SQL object is an SQL operation class object, the re_datas () function returns the queried array, and the SQL _numrows () function returns the number of queried call methods: $ sort_list = sort_list ($ sort_list, 0, 1 ); |