PHP unlimited classification presentation issues. I 've been tossing for a day. I can't help it.

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.