php / **************************************************************** ******* features: php associating with menu *********************** author: red star ********* ************************************************************************************************************************ ********* Date: 2004/10/02 ******************************************************************************* *********************************************************** ******* /
Require_once ('db.inc.php'); // Database connection $ db = new hq_online; $ db1 = new hq_online; $ db-> query ("Select * from news_bclass order by id desc"); $ fmenu = "" $ FVALUE = ""; while ($ db-> next_record ()) {$ fmenu. = "/" "$ db-> record [" BNAME "]." / ","; $ fvalue. = "/ "". $ db-> record ["id"]. "/";} $ fmenu = substr ($ fmenu, 0, (Strlen ($ fmenu) -1)); $ fmenu = "[". $ FMenu. "]"; // *********************************** Get VAR FMENU $ FVALUE = SUBSTR ($ FVALUE, 0, (Strlen ($ FVALUE) -1)))))))); $ fvalue = "[". $ fvalue. "]"; // ********************** ****** Get Var Fvalue
// Get ************************************** VAR SMENU $ DB-> Query ("SELECT * from news_bclass order by id desc" ); While ($ db-> next_record ()) {$ ParentID = $ db-> record ["id"]; $ db1-> query ("SELECT * from news_sclass where parentid = '$ parentid' Order by Parentid Desc" WHILE ($ db1-> next_record ()) {$ Num = $ db1-> num_rows (); $ i ; $ smenu. = "/" "$ Db1-> record [" sname "]." / " , "; IF ($ I == $ Num) {$ SMENU =" [". $ SMENU."], ["; $ I = 0;}}} $ SMENU. ="] "; $ SMENU = STR_REPLACE "/",], "/"] "; $ smenu = str_replace (", [] ","] ", $ smenu); if ((Substr ($ SMENU, 0, 2)) = = "[/") {$ SMENU = "[". $ SMENU;} else {$ SMENU = preg_replace ("// [{3,} / is", "[[// 1", $ smenu); // Match} // get *************************************** VAR SVALUE $ db-> query ("SELECT * from news_bclass order BY ID DESC "); While ($ db-> next_record ()) {$ ParentID = $ db-> record [" ID "]; $ db1-> query (" SELECT * from news_sclass where parentid = '$ ParentID' Order BY PARENTID DESC "); While ($ db1-> next_record ()) {$ NUMS = $ db1-> num_rows (); $ J ; $ sValue. =" / "" $ db1-> record ["id"] "/", "; $ J == $ nums) {$ sValue =" [". $ Svalue."], ["; $ J = 0;}}} $ sValue. = "]"; $ Svalue = str_replace ("/", € / "," / "]"; $ svalue = str_replace (", []", "]" $ Svalue); IF ((Substr ($ Svalue, 0, 2)) == "[/") {$ sValue = "[". $ svalue;} else {$ svalue = preg_replace ("// [{ 3,} / IS "," [[// 1 ", $ svalue); // match}
?>