如何为cms创建导航菜单? [英] How do I create nav menu for a cms?

查看:145
本文介绍了如何为cms创建导航菜单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个cms,我想为导航下拉菜单生成一组无序列表。首先,我从数据库中选择所有的菜单和链接,然后我想使用php(包括'main'列表的'child'列表,如果有的话)将它们作为无序列表输出
如何做

I'm creating a cms, I want to produce a set of unordered lists for a nav drop down menu. First, I select all of the menus and links from the database, then I want them to be outputed as unordered lists using php (including the 'main' list's 'child' list if there is one) How do I do it?

Main list->         <li><a href="#">Products</a>
                    <ul>
       Child list-> <li><a href="#">Foo</a></li>
                    </ul>
                    </li>


推荐答案

从数据库获得的结果存储为数组,你可以做一个foreach循环并迭代数据库结果,并做如下:

The result you get from database is stored as an array, you can do a foreach loop and iterate over the database result and do like this:

  <li><a href="#">Products</a>
  <?php 
  foreach($rows as $value)
  {
  //these are the child list items you got from database
  echo "<ul><li><a href="#">".$value."</a></li></ul>";
  } 
  ?>
  </li>

这篇关于如何为cms创建导航菜单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆