Function:
Infinite classification shows function get_str ($id = 0) { global $str; $sql = "Select Classid,classname,classstate,classtype,classurl,classpage,classorder,classtitle,classkeyword, Classdescription,classpid from Bz_class where classpid= $id "; $result = mysql_query ($sql);//The subclass of the query PID if ($result && mysql_affected_rows ()) {//If there is a subclass while ($row = Mysql_fetch_array ($result)) {//cyclic recordset $str. = "" $row [' ClassID ']. "". $row [' classname ']. "id:882233
". $row [' ClassType ']. "". $row [' ClassID ']. "". $row [' ClassID ']. "". $row [' ClassID ']. ""; String Build get_str ($row [' classid ']);//Call GET_STR (), pass the ID parameter in the recordset into the function, continue querying the subordinate } }
Ask Master enlighten.
Reply to discussion (solution)
Give it a try
Infinite classification shows function get_str ($id = 0, $depth =0) { global $str; $sql = "Select Classid,classname,classstate,classtype,classurl,classpage,classorder,classtitle,classkeyword, Classdescription,classpid from Bz_class where classpid= $id "; $result = mysql_query ($sql);//The subclass of the query PID if ($result && mysql_affected_rows ()) {//If there is a subclass while ($row = Mysql_fetch_array ($result)) {//cyclic recordset $str. = "". $row [' ClassID ']. "". Str_repeat ("└", $depth). $row [' classname ']. "id:882233
". $row [' ClassType ']. "". $row [' ClassID ']. "". $row [' ClassID ']. "". $row [' ClassID ']. ""; String construction get_str ($row [' ClassID '], $depth + 1),//Call GET_STR (), pass the ID parameter in the recordset into the function, continue querying the subordinate } }, return $str;}
Get_str ($row [' classid ']); Call Get_str (), pass the ID parameter in the recordset into the function, and continue querying the subordinate
The return of the $STR is not used.
Could you write me a code, please? Toss a day.
Reference: http://www.jb51.net/article/36220.htm
Give it a try
Infinite classification shows function get_str ($id = 0, $depth =0) { global $str; $sql = "Select Classid,classname,classstate,classtype,classurl,classpage,classorder,classtitle,classkeyword, Classdescription,classpid from Bz_class where classpid= $id "; $result = mysql_query ($sql);//The subclass of the query PID if ($result && mysql_affected_rows ()) {//If there is a subclass while ($row = Mysql_fetch_array ($result)) {//cyclic recordset $str. = "". $row [' ClassID ']. "". Str_repeat ("└", $depth). $row [' classname ']. "id:882233
". $row [' ClassType ']. "". $row [' ClassID ']. "". $row [' ClassID ']. "". $row [' ClassID ']. ""; String construction get_str ($row [' ClassID '], $depth + 1),//Call GET_STR (), pass the ID parameter in the recordset into the function, continue querying the subordinate } }, return $str;}
This can be used, Gao Ah, I toss a day, very grateful.