ID NAME PARENT_ID
1 Sales
2 Marketing 1
3 sales_optimiztaion.txt 2
5 list.xls 6
6 General data 1
我有数据和函数的层次表,它计算包含某些特定文件夹及其子文件夹的文件数。在这种情况下,文件夹Sales包含两个文件 - list.xls和sales_optimiztaion.txt。 功能:
<?
function get_pathS($node) {
global $countSS;
$result = mysql_query('SELECT NAME, PARENT_ID FROM b_disk_object
WHERE ID="'.$node.'";');
$ro = mysql_fetch_array($result);
if ($ro['NAME']!='') {
$path=$ro['NAME'];
if($path=='Sales'){
$countSS++;
$path=get_path($ro['PARENT_ID']);
}
$path=get_pathS($ro['PARENT_ID']);
}
return $countSS;
}?&gt;
功能正常,但我想通过&#39;销售&#39;作为这个函数的参数:
<?
function get_pathS($node, $manage) {
global $countSS;
$result = mysql_query('SELECT NAME, PARENT_ID FROM b_disk_object
WHERE ID="'.$node.'";');
$ro = mysql_fetch_array($result);
if ($ro['NAME']!='') {
$path=$ro['NAME'];
if($path==$manage){
$countSS++;
$path=get_path($ro['PARENT_ID']);
}
$path=get_pathS($ro['PARENT_ID']);
}
return $countSS;
} ?>
但在调用这样的函数之后:
while ($row = mysql_fetch_array($query)){
$check='Sales';
get_pathS($row['PARENT_ID'], $check);
.......
它不起作用。问题是什么?
答案 0 :(得分:1)
当你调用它时(在函数体中)
$path=get_pathS($ro['PARENT_ID']);
你也应该传递第二个参数。像这样
$path=get_pathS($ro['PARENT_ID'], $manage);