Commercial Bank Loan classification PHP recursive implementation of infinite classification generate a drop-down list of functions

Source: Internet
Author: User
Copy the Code code as follows:


/*—————————————————— */
– Recursive implementation of infinite classification generation drop-down list function
– $tpl->assign (' Sort_list ', createsortoptions ());
– $tpl->assign (' Sort_list ', createsortoptions ($sort _id));
/*—————————————————— */
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). $row [' Sort_name ']. " \ n ";
$options. =createsortoptions ($selected, $row [' sort_id '], $n);
}
}
return $options;
}

The above describes the Commercial Bank loan classification PHP recursive implementation of unlimited classification to generate a drop-down list of functions, including the Commercial Bank loan classification of the content, I hope the PHP tutorial interested in a friend helpful.

  • 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.