Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/246.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 菜单不能用了_Php_Mysql - Fatal编程技术网

Php 菜单不能用了

Php 菜单不能用了,php,mysql,Php,Mysql,因此,我创建了一个菜单,但我无法获得指向页面的链接。 在PHPmyadmin中,我有一个名为菜单的表 在该表中,您可以找到ID、Name、parentid(对于子菜单)和href(这些字段仅包含index.php/news.php等页面名称) 谷歌开发: <header> <div style="width: 100%; background-color: #383838; border-bottom: 4px solid #cd0000;">

因此,我创建了一个菜单,但我无法获得指向页面的链接。 在PHPmyadmin中,我有一个名为菜单的表

在该表中,您可以找到ID、Name、parentid(对于子菜单)和href(这些字段仅包含index.php/news.php等页面名称)


谷歌开发:

   <header>
    <div style="width: 100%; background-color: #383838; border-bottom: 4px solid #cd0000;">
        <div class="menu">
            <ul class="cssmenu"><a href="http://cvdemarskoppen.nl/"><li style="z-index: 100;">Home</li></a><a href="http://cvdemarskoppen.nl/"><li style="z-index: 100;">Nieuws</li></a><a href="http://cvdemarskoppen.nl/"></a><li style="z-index: 100;"><a href="http://cvdemarskoppen.nl/">De Marskoppen</a><ul class="cssmenu"><a href="http://cvdemarskoppen.nl/"></a><a href="http://cvdemarskoppen.nl/"><li style="z-index: 100;">Foto's</li></a><a href="http://cvdemarskoppen.nl/"><li style="z-index: 100;">Agenda</li></a><a href="http://cvdemarskoppen.nl/"><li style="z-index: 100;">Het Bestuur</li></a><a href="http://cvdemarskoppen.nl/"><li style="z-index: 100;">Historie</li></a><a href="http://cvdemarskoppen.nl/"><li style="z-index: 100;">Commissies</li></a><a href="http://cvdemarskoppen.nl/"><li style="z-index: 100;">Lid worden</li></a></ul></li><a href="http://cvdemarskoppen.nl/"></a><li style="z-index: 100;"><a href="http://cvdemarskoppen.nl/">Garde Officieren</a><ul class="cssmenu"><a href="http://cvdemarskoppen.nl/"></a><a href="http://cvdemarskoppen.nl/"><li style="z-index: 100;">Foto's</li></a><a href="http://cvdemarskoppen.nl/"><li style="z-index: 100;">Agenda</li></a><a href="http://cvdemarskoppen.nl/"><li style="z-index: 100;">Leden</li></a><a href="http://cvdemarskoppen.nl/"><li style="z-index: 100;">Historie</li></a></ul></li><a href="http://cvdemarskoppen.nl/"><li style="z-index: 100;">Vorstenhuis</li></a><a href="http://cvdemarskoppen.nl/"><li style="z-index: 100;">Sponsors</li></a></ul>   </div>
    </div>
        <div class="header">
            <div style="display: none; background-color: #fe0000; width: 30%; float: left; height: 199px; position: absolute; margin: 60px 0 0 0; border-top: 4px solid #3f454b; border-bottom: 4px solid #3f454b;"></div>
            <div style="width: 100%; float: left;">
            <div style="display: none; background-image: url('css/images/header/logo.png'); width: 209px; height: 208px; position: absolute; z-index: 4; float: right; margin: -4 0 0 180;"></div>
            </div>
            <div id="cycler" style="overflow:hidden;">
                <img class="active" src="css/images/header/1.jpg" alt="Plaats hier een foto." style="width: 100%; height: 150%; margin-top: -10%; display: block; z-index: 3;">
                <img src="css/images/header/2.jpg" alt="Plaats hier een foto." style="width: 100%; height: 150%; margin-top: -10%; z-index: 1; display: block;" class="">   
                <img src="css/images/header/3.jpg" alt="Plaats hier een foto." style="width: 100%; height: 150%; margin-top: -10%; z-index: 1; display: block;" class="">           
            </div>
        </div>
        <div class="clear"></div>
        <script>
    function cycleImages(){
          var $active = $('#cycler .active');
          var $next = ($active.next().length > 0) ? $active.next() : $('#cycler img:first');
          $next.css('z-index',2);//move the next image up the pile
          $active.fadeOut(1500,function(){//fade out the top image
          $active.css('z-index',1).show().removeClass('active');//reset the z-index and unhide the image
              $next.css('z-index',3).addClass('active');//make the next image the top one
          });
        }

    $(document).ready(function(){
    // run every 7s
    setInterval('cycleImages()', 7000);
    })
        </script>

    </header>

              • 函数cycleImages(){ var$active=$('#cycler.active'); var$next=($active.next().length>0)?$active.next():$(“#cycler img:first”); $next.css('z-index',2);//将下一个图像向上移动 $active.fadeOut(1500,function(){//淡出顶部图像 $active.css('z-index',1).show().removeClass('active');//重置z-index并取消隐藏图像 $next.css('z-index',3).addClass('active');//使下一个图像成为顶部图像 }); } $(文档).ready(函数(){ //每7秒跑一次 setInterval('cycleImages()',7000); })
我为菜单写的Html

<header>
<div style="width: 100%; background-color: #383838; border-bottom: 4px solid #cd0000;">
    <div class="menu">
        <?php display_menus(); ?>
    </div>
</div>

谢谢你的帮助。记住,这对我来说是反复试验。php新手,所以我仍在学习所有知识。

谷歌开发:

   <header>
    <div style="width: 100%; background-color: #383838; border-bottom: 4px solid #cd0000;">
        <div class="menu">
            <ul class="cssmenu"><a href="http://cvdemarskoppen.nl/"><li style="z-index: 100;">Home</li></a><a href="http://cvdemarskoppen.nl/"><li style="z-index: 100;">Nieuws</li></a><a href="http://cvdemarskoppen.nl/"></a><li style="z-index: 100;"><a href="http://cvdemarskoppen.nl/">De Marskoppen</a><ul class="cssmenu"><a href="http://cvdemarskoppen.nl/"></a><a href="http://cvdemarskoppen.nl/"><li style="z-index: 100;">Foto's</li></a><a href="http://cvdemarskoppen.nl/"><li style="z-index: 100;">Agenda</li></a><a href="http://cvdemarskoppen.nl/"><li style="z-index: 100;">Het Bestuur</li></a><a href="http://cvdemarskoppen.nl/"><li style="z-index: 100;">Historie</li></a><a href="http://cvdemarskoppen.nl/"><li style="z-index: 100;">Commissies</li></a><a href="http://cvdemarskoppen.nl/"><li style="z-index: 100;">Lid worden</li></a></ul></li><a href="http://cvdemarskoppen.nl/"></a><li style="z-index: 100;"><a href="http://cvdemarskoppen.nl/">Garde Officieren</a><ul class="cssmenu"><a href="http://cvdemarskoppen.nl/"></a><a href="http://cvdemarskoppen.nl/"><li style="z-index: 100;">Foto's</li></a><a href="http://cvdemarskoppen.nl/"><li style="z-index: 100;">Agenda</li></a><a href="http://cvdemarskoppen.nl/"><li style="z-index: 100;">Leden</li></a><a href="http://cvdemarskoppen.nl/"><li style="z-index: 100;">Historie</li></a></ul></li><a href="http://cvdemarskoppen.nl/"><li style="z-index: 100;">Vorstenhuis</li></a><a href="http://cvdemarskoppen.nl/"><li style="z-index: 100;">Sponsors</li></a></ul>   </div>
    </div>
        <div class="header">
            <div style="display: none; background-color: #fe0000; width: 30%; float: left; height: 199px; position: absolute; margin: 60px 0 0 0; border-top: 4px solid #3f454b; border-bottom: 4px solid #3f454b;"></div>
            <div style="width: 100%; float: left;">
            <div style="display: none; background-image: url('css/images/header/logo.png'); width: 209px; height: 208px; position: absolute; z-index: 4; float: right; margin: -4 0 0 180;"></div>
            </div>
            <div id="cycler" style="overflow:hidden;">
                <img class="active" src="css/images/header/1.jpg" alt="Plaats hier een foto." style="width: 100%; height: 150%; margin-top: -10%; display: block; z-index: 3;">
                <img src="css/images/header/2.jpg" alt="Plaats hier een foto." style="width: 100%; height: 150%; margin-top: -10%; z-index: 1; display: block;" class="">   
                <img src="css/images/header/3.jpg" alt="Plaats hier een foto." style="width: 100%; height: 150%; margin-top: -10%; z-index: 1; display: block;" class="">           
            </div>
        </div>
        <div class="clear"></div>
        <script>
    function cycleImages(){
          var $active = $('#cycler .active');
          var $next = ($active.next().length > 0) ? $active.next() : $('#cycler img:first');
          $next.css('z-index',2);//move the next image up the pile
          $active.fadeOut(1500,function(){//fade out the top image
          $active.css('z-index',1).show().removeClass('active');//reset the z-index and unhide the image
              $next.css('z-index',3).addClass('active');//make the next image the top one
          });
        }

    $(document).ready(function(){
    // run every 7s
    setInterval('cycleImages()', 7000);
    })
        </script>

    </header>

              • 函数cycleImages(){ var$active=$('#cycler.active'); var$next=($active.next().length>0)?$active.next():$(“#cycler img:first”); $next.css('z-index',2);//将下一个图像向上移动 $active.fadeOut(1500,function(){//淡出顶部图像 $active.css('z-index',1).show().removeClass('active');//重置z-index并取消隐藏图像 $next.css('z-index',3).addClass('active');//使下一个图像成为顶部图像 }); } $(文档).ready(函数(){ //每7秒跑一次 setInterval('cycleImages()',7000); })
我为菜单写的Html

<header>
<div style="width: 100%; background-color: #383838; border-bottom: 4px solid #cd0000;">
    <div class="menu">
        <?php display_menus(); ?>
    </div>
</div>


谢谢你的帮助。记住,这对我来说是反复试验。php新手,所以我仍在学习所有内容。

您的链接组装不正确,因为您没有循环通过
href
数组的值来附加到
html
变量

您只是在
$array[$parent\u id]
中循环,然后尝试将
$href
数组(不是它的值)附加到
$html
变量

这基本上为您提供了
http://mywebsite.com/array
或者干脆
http://mywebsite.com/
在DOM中

您需要为
$html
数组添加一个循环,如下所示:

$html = 'http://mywebsite.com/';

$href = array('a', 'b', 'c'); //this comes from your db as per your question

$link = '';
$link .= '<ul>';

foreach($href as $val){
    $link .= '<a href="' . $html . $val . '"><li style="z-index: 100;"></li></a>';
}

$link .= '</ul>';
echo $link;
$html='1!'http://mywebsite.com/';
$href=array('a','b','c')//根据您的问题,这来自您的数据库
$link='';
$link.='
    '; foreach($href作为$val){ $link.=''; } $link.='
'; echo$link;
这将在DOM中为您提供以下内容:

<ul>
 <a href="http://mywebsite.com/a"><li style="z-index: 100;"></li></a>
 <a href="http://mywebsite.com/b"><li style="z-index: 100;"></li></a>
 <a href="http://mywebsite.com/c"><li style="z-index: 100;"></li></a>
</ul>

您的链接组装不正确,因为您没有循环通过
href
数组的值来附加到
html
变量

您只是在
$array[$parent\u id]
中循环,然后尝试将
$href
数组(不是它的值)附加到
$html
变量

这基本上为您提供了
http://mywebsite.com/array
或者干脆
http://mywebsite.com/
在DOM中

您需要为
$html
数组添加一个循环,如下所示:

$html = 'http://mywebsite.com/';

$href = array('a', 'b', 'c'); //this comes from your db as per your question

$link = '';
$link .= '<ul>';

foreach($href as $val){
    $link .= '<a href="' . $html . $val . '"><li style="z-index: 100;"></li></a>';
}

$link .= '</ul>';
echo $link;
$html='1!'http://mywebsite.com/';
$href=array('a','b','c')//根据您的问题,这来自您的数据库
$link='';
$link.='
    '; foreach($href作为$val){ $link.=''; } $link.='
'; echo$link;
这将在DOM中为您提供以下内容:

<ul>
 <a href="http://mywebsite.com/a"><li style="z-index: 100;"></li></a>
 <a href="http://mywebsite.com/b"><li style="z-index: 100;"></li></a>
 <a href="http://mywebsite.com/c"><li style="z-index: 100;"></li></a>
</ul>

这是一个由PHP代码和HTML混合而成的混乱局面。你想干什么?为什么不能进一步分开?
$html.$href.
这是什么意思?欢迎来到StackOverflow!请查看有关提出好问题的更多信息。在这种情况下,如果你能提供一个例子来说明你所遇到的问题,可能会对你和回答问题的人有所帮助。你想干什么?为什么不能进一步分开?
$html.$href.
这是什么意思?欢迎来到StackOverflow!请查看有关提出好问题的更多信息。在这种情况下,如果你能提供一个例子来说明你所遇到的问题,可能会对你和回答问题的人有所帮助。我明白你的意思。但是我不能确定代码的位置。你是说.php文件吗?或者是哥伦布。这里是我使用“a、b和c”作为示例代码的数据库构建的图像,但这些是从数据库中获取的.php文件,要添加到
$html
。您需要重构代码以获得
href
值。有几种方法可以做到这一点,您甚至可以在first foreach循环中使用
array_pop()
每次获取
href
的最后一个值,并将其附加到
$html
我明白了您的意思。但是我不能确定代码的位置。你是说.php文件吗?或者是哥伦布。这里有一个ima