The problem of the display of PHP infinite class classification. It's been a day.

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