The code is as follows:
<code>//返回指定的$aid 的工程类别id和他的下级类别id //参数: // $aid 工程类别, int类型 // $conn 数据库连接 // $str,返回值,字符串类型 // 返回: 字符串,类似于 "1,3,7,8," function get_gongchengleibie($aid, &$str, $conn){ $str = ""; $query=mysql_query(" select * from gongchengleibie where pid=$aid",$conn); while($row=mysql_fetch_array($query)) { $str .= $row["id"].","; get_gongchengleibie($row["id"], $str1, $conn); } } </code>
gongchengleibie is a database table with a 3-layer tree structure, as shown below
I want to remove the reference parameter $str and use the return value instead, but my attempt failed.
How to change it?
If it cannot be changed, what is the reason?
Thank you all for your attention or answers.
If there is incomplete information or unclear description of the problem, sorry please let me know and I will add it immediately.
The code is as follows:
<code>//返回指定的$aid 的工程类别id和他的下级类别id //参数: // $aid 工程类别, int类型 // $conn 数据库连接 // $str,返回值,字符串类型 // 返回: 字符串,类似于 "1,3,7,8," function get_gongchengleibie($aid, &$str, $conn){ $str = ""; $query=mysql_query(" select * from gongchengleibie where pid=$aid",$conn); while($row=mysql_fetch_array($query)) { $str .= $row["id"].","; get_gongchengleibie($row["id"], $str1, $conn); } } </code>
gongchengleibie is a database table with a 3-layer tree structure, as shown below
I want to remove the reference parameter $str and use the return value instead, but my attempt failed.
How to change it?
If it cannot be changed, what is the reason?
Thank you all for your attention or answers.
If there is incomplete information or unclear description of the problem, sorry please let me know and I will add it immediately.
Just change it to this, I won’t say more.
<code>function get_gongchengleibie($aid, $conn){ $str = ""; $query=mysql_query(" select * from gongchengleibie where pid=$aid",$conn); while($row=mysql_fetch_array($query)) { $str .= $row["id"].","; $str .= get_gongchengleibie($row["id"], $conn); } return $str; } </code>