I would be grateful for some help.
I have a very basic dynamic site, from a tutorial, the root directory is made up of the following
index.php
an inc folder that contains
home.php
contact.php
product.php
services.php
fetchmeta.php
Depending on selection through navbar (index calls in the selected page) I want to display the meta data and title related to that page. At the moment all I get is the homepage meta data displaying on all pages.
I have been trying to get this working for a week now with input from several people but I am still not managing to get it to work.
My script for retrieving data from the MySQL DB is
[php]
<?php include 'connect.php'; $page_id = 'meta_id'; $title = 'title'; $pname = 'name'; $desc = 'description'; $key = 'keywords'; $aut = 'author'; $copyr = 'copyright'; $email = 'email'; $rating = 'rating'; $robots = 'robots'; $visit = 'revisit'; $exp = 'expires'; $dist = 'distribution'; $sql = "SELECT * FROM `meta_data` WHERE `meta_id` = {$page_id}"; $query = $db->query($sql); $row = $query->fetch(PDO::FETCH_ASSOC); unset ($row['meta_id']) ; // discard that one foreach ($row as $desc => $content) { echo "\n" ; } echo "" . $title . "\n"; ?>[/php]
index.php is
[php]
<?php require_once 'inc/header.php'; ?>Sorry that page does not exist.
You will be redirected in 5 seconds to the homepage."; header("refresh:5; index.php"); } } else { include ($pages_dir.'/home.php'); } ?>
I do have this working in a static site using the same DB as well as putting <?php $page_id = # ?> on each page however when I came to try to insert into the dynamic site I have totally lost my way.
Thanks in advance