- Edited
I have a working menu for my dynamic pdo based site. All the links work in regards to displaying data, but the issue is that all of the menu links are shown - seven in all. What I would like to do is have three menu links on the top, and the remaining four in the footer. I am using to database tables - topmenu and footermenu.
This is the current code for the index.page:
<?php require_once("db.php");
// top nav menu
$data = array();
$sql = $conn->query("SELECT `id`, `pageheader`, `pagetitle`, `pagecontent` FROM topmenu ORDER BY id ASC");
$data = $sql->fetchAll(PDO::FETCH_UNIQUE);
$id = (isset($_GET['id']) && array_key_exists($_GET['id'],$data) ? $_GET['id'] : 1);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>test</title>
<link href="css/pagestyles.css" rel="stylesheet">
</head>
<body>
<?php include("includes/top.php") ?>
<nav class="nav">
<span class="nav__list">
<?php
foreach($data as $rid => $row):
echo '<a href="index.php?id='.$rid.'">'.$row['pageheader'].'</a>';
endforeach;
?>
</span>
</nav>
<hr>
<h1 class="center"><?php echo $data[$id]['pagetitle']; ?></h1>
<hr>
<?php echo $data[$id]['pagecontent']; ?>
<div class="space"></div>
<!-- footer content -->
<?php include('includes/footer.php'); ?>
</body>
</html>
footer: <footer>Email: admin@######.com | ####### ©
<?php echo date('Y'); ?>. All rights reserved.
<small>
<?php
foreach($data as $rid => $row):
echo '<a href="index.php?pageheader='.$rid.'">'.$row['pageheader'].'</a>';
endforeach;
?>
</small>
</footer>
The last section is in a include: <?php include('includes/footer.php'); ?> is this helps.
I would like to know how to separate the menu items but don't know how.