Unlimited classification implemented by php and mysql | relationship between tree display classification

Source: Internet
Author: User
Unlimited classification implemented by php and mysql | relationship between tree display classification

  1. // $ Count indicates the classification level
  2. Sort_list ($ str, $ fatherid, $ count)
  3. {
  4. $ Rs = $ this-> SQL-> re_datas ("select * from sort where father_id = fatherid ");
  5. $ Num = $ this-> SQL-> SQL _numrows ();
  6. $ I = 0;
  7. $ N = 1;
  8. While (isset ($ rs [$ I])
  9. {
  10. $ Name = "";
  11. For ($ n = 1; $ n <$ count; $ n ++)
  12. {
  13. $ Name. = "│ ";
  14. }
  15. If ($ I + 1 = $ num)
  16. {
  17. $ Name. = "example-". $ rs [$ I] [name];
  18. }
  19. Else
  20. {
  21. $ Name. = "example-". $ rs [$ I] [name];
  22. }
  23. If ($ rs [$ I] [isdir])
  24. {
  25. $ Str. = "". $ name ."";
  26. }
  27. Else
  28. {
  29. $ Str. = $ name ";
  30. }
  31. $ Temp = $ count + 1;
  32. $ Str = $ this-> sort_list ($ str, $ rs [$ I] [id], $ temp );
  33. $ I ++;
  34. }
  35. Return $ str;
  36. }
  37. ?>

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 );

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.