PHP unlimited classification presentation issues. I 've been tossing for a day. I can't help it. function:
// 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 ); // query the classification of the pid subclass if ($ result & mysql_affected_rows () {// if the subclass while ($ row = mysql_fetch_array ($ result )) {// cyclic record set $ str. ="". $ Row ['classid ']."". $ Row ['classname']."ID: 882233
". $ Row ['classtype ']."". $ Row ['classid ']."". $ Row ['classid ']."". $ Row ['classid '].""; // String construct get_str ($ row ['classid ']); // call get_str () to pass the id parameter in the record set to the function, continue querying lower-level} return $ str ;}
Please enlighten me.
Reply to discussion (solution)
Try
// 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 ); // query the classification of the pid subclass if ($ result & mysql_affected_rows () {// if the subclass while ($ row = mysql_fetch_array ($ result )) {// cyclic record set $ str. ="". $ Row ['classid ']."". Str_repeat (" break ", $ depth). $ row ['classname']."ID: 882233
". $ Row ['classtype ']."". $ Row ['classid ']."". $ Row ['classid ']."". $ Row ['classid '].""; // String construction get_str ($ row ['classid '], $ depth + 1); // call get_str () to pass the id parameter in the record set to the function, continue querying lower-level} return $ str ;}
Get_str ($ row ['classid ']); // call get_str () to pass the id parameter in the record set to the function and continue querying the lower-level
$ Str returned in this sentence is not used.
Could you write a code for me to learn? I 've been tossing for a day.
Reference: http://www.jb51.net/article/36220.htm
Try
// 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 ); // query the classification of the pid subclass if ($ result & mysql_affected_rows () {// if the subclass while ($ row = mysql_fetch_array ($ result )) {// cyclic record set $ str. ="". $ Row ['classid ']."". Str_repeat (" break ", $ depth). $ row ['classname']."ID: 882233
". $ Row ['classtype ']."". $ Row ['classid ']."". $ Row ['classid ']."". $ Row ['classid '].""; // String construction get_str ($ row ['classid '], $ depth + 1); // call get_str () to pass the id parameter in the record set to the function, continue querying lower-level} return $ str ;}
This can be used. hi! I 've been tossing for a day. thank you very much.