Php code for returning list data with an infinite array _ PHP Tutorial

Source: Internet
Author: User
Php returns the code for the list of infinitely classified data with arrays. Copy the code as follows: * ---------------- *-obtain the list data of an infinite category *------------------ The code is as follows:


/*------------------*/
//-Obtain the list data of an unlimited category
/*------------------*/
Function get_sort ($ parent_id = 0, $ n =-1)
{
Global $ db;
Static $ sort_list = array ();
$ SQL = "SELECT * FROM". $ db-> table ('article _ sort '). "WHERE 'parent _ id' =' {$ parent_id }'";
$ Res = $ db-> query ($ SQL );
If ($ res)
{
$ N ++;
While ($ row = $ db-> fetch_assoc ($ res ))
{
$ SQL = "SELECT * FROM ". $ db-> table ('article _ sort '). "WHERE 'parent _ id' = '{$ row ['sort _ id']}'";
$ Children = $ db-> num_rows ($ SQL );
$ Row ['sort _ name'] = str_repeat ('', $ n * 4). $ row ['sort _ name'];
$ Row ['Children '] = $ children;
$ Sort_list [] = $ row;
Get_sort ($ row ['sort _ id'], $ n );
}
}
Return $ sort_list;
}

The http://www.bkjia.com/PHPjc/322311.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/322311.htmlTechArticle code is as follows:/* ---------------- * //-get the list data of infinite classification /*------------------...

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.