Php recursive function_php tutorial

Source: Internet
Author: User
Php recursive functions with unlimited classification. This infinite classification php recursive function is a recursive php and SQL query method. it is very simple to query a query without any subclass of the current category. if so, you can call the function itself to operate it, this infinite classification php recursive function is a recursive php and SQL query method. it is very simple to query a query without any subclass of the current category. if so, you can call the function itself to operate it, if no subclass exists, the system returns the result.

This infinite classification php Tutorial recursive function is a php and SQL query recursive method, it is very simple to query a current classification does not have a subclass, if there is a, then call the function itself to operate, if no subclass exists, the system returns the result.

Function createsortoptions ($ selected = 0, $ parent_id = 0, $ n =-1)
{
Global $ db;
$ SQL = "select * from '@__ article_sort 'where' parent _ id' =' {$ parent_id }'";
$ Options = ";
Static $ I = 0;
If ($ I = 0)
{
$ Options. =' If ($ row ['sort _ id'] = $ selected)
{
$ Options. = 'selected ';
}
$ Options. = ">". str_repeat ('', $ n * 3). $ row ['sort _ name']."N ";
$ Options. = createsortoptions ($ selected, $ row ['sort _ id'], $ n );
}
}
Return $ options;
}

If you are using the smarty template, you can call

//-$ Tpl-> assign ('sort _ list', createsortoptions ());
//-$ Tpl-> assign ('sort _ list', createsortoptions ($ sort_id ));

Recursive functions are a recursive method for php and SQL queries. it is very simple to query a query without any subclass of the current category. if so, you can call the function itself to operate it ,...

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.