코드 복사 코드는 다음과 같습니다.
/*——————————————— ——* /
//– 무한 분류 생성 드롭다운 목록 기능의 재귀 구현
//– $tpl->ass('sort_list',createSortOptions ())
//– $ tpl->할당( 'sort_list',createSortOptions ($sort_id))
/*——————————————————— */
함수 createSortOptions ($selected=0,$parent_id= 0,$n=-1)
{
global $db;
$sql = "SELECT * FROM `@__article_sort` WHERE `parent_id` = '{ $parent_id}'";
$ 옵션 = ";
static $i = 0
if ($i == 0)
{
$options .= '<옵션 값 ="0″ >선택하세요< /option>';
}
$res = $db->query ($sql);
if ($res)
{
$n ;
while ($ row = $db->fetch_assoc ($res))
{
$i
$options .="n"
$options .=createSortOptions ($selected,$row[' sort_id'],$n);
}
}
$options 반환
}
위 내용은 PHP를 이용한 상업은행 대출분류 기능을 소개하여 무한분류를 재귀적으로 구현하고, 상업은행 대출분류 내용을 포함하여 드롭다운 목록을 생성하는 내용을 PHP 튜토리얼에 관심있는 친구들에게 도움이 되었으면 좋겠습니다.