A PHP two-level linkage _php tutorial with database

Source: Internet
Author: User
/*******************************************
Function: PHP Two-level linkage menu *************
Author: Chong Xing *************************
email:njj@nuc.edu.cn**************
Date: 2004/10/02******************
Please retain the copyright information when reproduced **************
*******************************************/
Require_once (' db.inc.php ');//Database connection
$db =new Hq_online;
$db 1=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"];
$db 1->query ("select * from News_sclass where parentid= ' $parentid ' ORDER by parentid DESC");
while ($db 1->next_record ()) {
$num = $db 1->num_rows ();
$i + +;
$sMenu. = "". $db 1->record["sname"]. "", ";
if ($i = = $num) {
$sMenu = "[". $sMenu. "],[";
$i = 0;
}
}
}
$sMenu. = "]";
$sMenu =str_replace ("",] "," "]", $sMenu);
$sMenu =str_replace (", []", "]", $sMenu);
if ((substr ($sMenu, 0,2)) = = "[" ") {
$sMenu = "[". $sMenu;
}else{
$sMenu =preg_replace ("/[{3,}/is", "[[1], $sMenu);//Match

http://www.bkjia.com/PHPjc/445577.html www.bkjia.com true http://www.bkjia.com/PHPjc/445577.html techarticle /******************************************* ********** function: PHP level Two linkage menu ************* ********** Author: Chong Xing ************ email:njj@nuc.edu.cn*** ...

  • 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.