douxi0098 2013-05-12 14:04
浏览 42
已采纳

Codeigniter,动态菜单来自数据库

I am Trying to Implement the Dynamic Menus

i Have two Tables in my Database pbs_forms includes Form Path Form Path link etc enter image description here

Second Table Name is pbs_formsingroups it shows that form belongs to which group enter image description here

Here is how right now i am getting data in my view

$GetForms=$this->CommonModel->get_by_join($columns,$PTable,$joins,$where);

foreach($GetForms as $key => $row){
    list($NavBar, $MainMenu, $SubMenu) = explode("/", $row['FormPath']);
    $arrayLeftMenuList = array();
    $arrayLeftMenuList[$key]['NavBarMenuLink'] = $NavBar;
    $arrayLeftMenuList[$key]['LeftMainMenu'] = $MainMenu;
    $arrayLeftMenuList[$key]['LeftSubMenu'] = $SubMenu;
    $arrayLeftMenuList[$key]['FormCIPath'] = $row['FormCIPath'];
    $arrayLeftMenuList[$key]['MainMenu_OrderNo'] = $row['Order_MainMenu_No'];
    $arrayLeftMenuList[$key]['SubMenu_OrderNo'] = $row['Order_SubMenu_No'];
    $arrayLeftMenuList[$key]['HaveSubMenus'] = $row['SubMenu'];
}

Data is Coming from the Database Fine..

Now When i Try This in Code:

foreach($arrayLeftMenuList as $key => $value){
    echo $arrayLeftMenuList[$key]['LeftSubMenu'];
}

In Result I only Get

Users

Instead I should Be Getting Both Search Prize Bond and Users?

Can Anyone Understand the Problem i have Stated above and Show me a solution that how to solve this issue?

  • 写回答

1条回答 默认 最新

  • doue9730 2013-05-12 15:28
    关注

    My Mistake, Got The Solution, This was a Plain Mistake that i could not find before.

    I changed

    $arrayLeftMenuList = array();
    

    to

    $arrayLeftMenuList[$key] = array();
    

    and now its working Great. :)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 使用yolov5-7.0目标检测报错
  • ¥15 对于这个问题的解释说明
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败
  • ¥20 java在应用程序里获取不到扬声器设备