Here is my revised code:
I can get the default.php template stay put but my content is saying error querying database. I wonder why?
NAVIGATION
Code:
<?php
//Connect to the db
$conn = mysqli_connect($host, $username, $password, $dbname) or die('Error connecting to MySQL server.');
//select the url
$sql = "SELECT * FROM web_pages;";
$result = mysqli_query($conn, $sql) or die('Error querying database.');
//loop through the page titles to populate the navigation bar
while ($row = mysqli_fetch_array($result)) {
echo '<ul><li><a href="default.php?id='.$row["id"].'">'.$row["page_title"].'</a></li></ul>';
}
mysqli_close($conn);
?>
CONTENT
Code:
<?php
$conn = mysqli_connect($host, $username, $password, $dbname) or die('Error connecting to MySQL server.');
//select the url
$sql = "SELECT * FROM web_pages WHERE id = $_GET[id]";
$result = mysqli_query($conn, $sql) or die('Error querying database.');
//loop through the page titles to populate the content box
while ($row = mysqli_fetch_array($result)) {
$id = $row['id'];
$page_title = $row['page_title'];
$url = $row['url'];
$content = $row['content'];
}
mysqli_close($conn);
?>
<?php
echo '<tr><td>' . $row['page_title'] . '</td>
<td>' . $row['content'] . '</td>';
?>