The code is as follows: {code...} gongchengleibie is a database table with a three-layer tree structure. if you want to remove the reference parameter $ str, use the return value method and try again. How can I change it? If it cannot be changed, why? Thank you for your attention or answers. Such...
The code is as follows:
// Return the specified $ aid Project Category id and its subordinate category id. // parameter: // $ aid project category, int type // $ conn database connection // $ str, return value, string type // return: string, similar to "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 );}}
Gongchengleibie is a database table with a three-layer tree structure, as shown in figure
I want to remove the reference parameter $ str and use the return value method. I failed to try it myself.
How can I change it?
If it cannot be changed, why?
Thank you for your attention or answers.
If the information is incomplete or the problem description is unclear, I will immediately add a message to the sorry + request.
Reply content:
The code is as follows:
// Return the specified $ aid Project Category id and its subordinate category id. // parameter: // $ aid project category, int type // $ conn database connection // $ str, return value, string type // return: string, similar to "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 );}}
Gongchengleibie is a database table with a three-layer tree structure, as shown in figure
I want to remove the reference parameter $ str and use the return value method. I failed to try it myself.
How can I change it?
If it cannot be changed, why?
Thank you for your attention or answers.
If the information is incomplete or the problem description is unclear, I will immediately add a message to the sorry + request.
You just need to change it to this. if you have more, you won't talk about it.
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;}