gpt4 book ai didi

php - 无法使用菜单

转载 作者:太空宇宙 更新时间:2023-11-03 11:42:01 25 4
gpt4 key购买 nike

所以我创建了一个菜单,但我无法获得页面的链接。在 PHPmyadmin 中,我有一个名为 menus 的表。

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

   <?php include 'assets/class/dbcon.php'; ?>

<?php
function loop_array($array = array(), $parent_id = 0){
$html = 'http://mywebsite.com/';
global $connection;
$result = mysqli_query($connection,"SELECT href FROM menus");
$href = Array();
while ($row = mysqli_fetch_array($result)) {
$href = $row['href'];

}
if(!empty($array[$parent_id])){

echo '<ul class="cssmenu">';
foreach($array[$parent_id] as $items){
echo '<a href="'.$html.$href.'"><li style="z-index: 100;">';
echo $items['name'];
loop_array($array, $items['id']);
echo '</li></a>';
}
echo '</ul>';

}
}

function display_menus()
{


global $connection;
$query = $connection->query("SELECT * FROM menus");
$array = array();

if(mysqli_num_rows($query)){

while($rows = mysqli_fetch_array($query)){

$array[$rows['parent_id']][] = $rows;

}
loop_array($array);
}


}

mysqli_close($connection);
?>

我的想法是,当我点击 li 标签时, 那是加载http://mywebsite.com/variouspages.php但它现在所做的是,当我点击一个 li 标签时,它会将我送回 mywebsite.com。如果我回显 href 列,它会显示所有 href 链接。所以它说类似 index.phpnews.phpfotos.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>

我为菜单编写的 HTML。

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

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

关于php - 无法使用菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41108488/

25 4 0