php4me Posted February 8, 2014 Share Posted February 8, 2014 Hi, I am not sure if I understand this right, if I want to use the same template you're using in the book, then the header page completly changes from the code in the download to the code in the book? Here is the code that I put from the book, but it gives me error when I view the site. <!DOCTYPE html><html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="description" content=""> <meta name="author" content=""> <title><?php // Use a default page title if one wasn't provided... if (isset($page_title)) { echo $page_title; } else { echo 'Virtual Script'; } ?></title> <!-- Bootstrap core CSS --> <link href="css/bootstrap.min.css" rel="stylesheet"> <!-- Custom styles for this template --> <link href="css/sticky-footer-navbar.css" rel="stylesheet"> </head> <body><?php // <!-- Wrap all page content here --> $page = array ( 'Home' => 'index.php', 'About' => 'about.php', 'Contact' => 'contact.php', 'Register' => 'register.php' ); $this_page = basename($_SERVER['PHP_SELF']); foreach ($page as $k => $v) { echo '<li'; if ($this_page = $v) echo ' class="active"'; echo '><a href="' . $v . '">' . $k . '</a></li>';} // END OF FOREACH LOOP. if (isset($_SESSION['user_id'])) { echo '<li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">Account <b class="caret"></b></a> <ul class="dropdown-menu"> <li><a href="logout.php">Logout</a></li> <li><a href="renew.php">Renew</a></li> <li><a href="change_password.php">Change Password</a></li> <li><a href="favorites.php">Favorites</a></li> <li><a href="recommendations.php">Recommendations</a></li> </ul> </li>';} if(isset($_SESSION['user_admin'])) { echo '<li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">Admin <b class="caret"></b></a> <ul class="dropdown-menu"> <li><a href="add_page.php">Add Page</a></li> <li><a href="add_pdf.php">Add PDF</a></li> <li><a href="#">Something else here</a></li> </ul> </li>'; } ?> <?php$q = 'SELECT * FROM categories ORDER BY categories';$r = mysqli_query($dbc, $q);while (list($id, $category) = mysqli_fetch_array($r, MYSQLI_NUM)) { echo '<a href="category.php?id=' . $id . '" class="list-group-item="' . $category . '">' . htmlspecialchars($category) . '</a>'; } ?> <?phpif (!isset($_SESSION['user_id'])) {require('includes/login_form.inc.php');}?> <div class="col-9"><!-- CONTENT --> </html> Thanks very much. Link to comment Share on other sites More sharing options...
Larry Posted February 10, 2014 Share Posted February 10, 2014 What is the error? Link to comment Share on other sites More sharing options...
php4me Posted February 11, 2014 Author Share Posted February 11, 2014 Hi, I fixed the error but the page layout is gone, so I had to reupload the header file, I am trying to get the same template as shown in the book but I can't get rid of the drobdown top menu to make the links appear at the top. Thanks Link to comment Share on other sites More sharing options...
Larry Posted February 18, 2014 Share Posted February 18, 2014 What do you mean by "the page layout is gone"? It might also help if you explained what your URL is and what your directory structure is. Link to comment Share on other sites More sharing options...
Recommended Posts