无限分类php 递归函数
这款无限分类php 递归函数是一款php 与sql查询递归的方法,很简单就是查询一次当前分类没有没子类,如果有的话就再调用函数本身来操作,如果己经没有子类了就可以返回了。
这款无限分类php教程 递归函数是一款php 与sql查询递归的方法,很简单就是查询一次当前分类没有没子类,如果有的话就再调用函数本身来操作,如果己经没有子类了就可以返回了。
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;
}
如果是用smarty模板的朋友可以如下调用
//– $tpl->assign('sort_list',createsortoptions ());
//– $tpl->assign('sort_list',createsortoptions ($sort_id));

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

SublimeText3 Linux new version
SublimeText3 Linux latest version

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SublimeText3 English version
Recommended: Win version, supports code prompts!

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.
