I have a website where the main navigation links to other pages via a database (SELECT FROM etc) that works. Within one of the pages are links to other pages (also on a database). What I want to do is have this other link load in data just like the main menu does. I have tried using a version of the main navigation to do this but the PHP code appears as text or not at all.
This is the version of the PHP I wanted to use:
<?php
$q = "SELECT * FROM pages WHERE id = **";
$r = mysqli_query($dbh, $q);
while( $nav = mysqli_fetch_assoc($r) ){
echo '<a href="' . $nav['slug'] . '">' . $nav['pagelinks'] . '</a>';
}
?>
This just appear as text. This code was in the database page i.e.
<p class="default">
<?php echo "test"; ?>
<a href="Hedju Hor.html" target="_blank">Hedju Hor</a>
</p>
The ‘test’ was where the code was and replaced to test the PHP. The page (html) would be replaced by the link - Part of page I want displayed is in the same database as the page the link is in - ie. page 4, the link to the page I want is **.
How do I get the database page to view?
I think it’s because their is no link to the database. If this is the case, where would I place this link?
I add two images, one is the page as viewed online, and the other is the database entry.
Any help would be appreciated.