I am sure there are more people doing this, for my website I load different meta content trough a database for each and every page.
Easy and smart!
index.php
PHP Code:
Page_name = 'index';
include_once('PAGE_DATA.php');
HTML_HEAD($page_title,$meta_description,$meta_keywords)
PAGE_DATA.php
PHP Code:
<?php
DB_CONNECT ();
// we need to connect to our database;
$result = mysql_query("SELECT * FROM pages WHERE Page_name='$Page_name'");
if ($result == false || mysql_num_rows($result) == 0)
{
header("location:error.php?id=4");
}
else
{
$data = mysql_fetch_array($result);
$meta_description = $data['meta_content'];
$meta_keywords = $data['meta_keywords'];
$page_title = $data['Page_title'];
}
DB_DISCONNECT ();
?>
function to print html header
PHP Code:
function HTML_HEAD ($page_title,$meta_description,$meta_keywords)
{
echo '<head>';
echo '<LINK REL="SHORTCUT ICON" HREF="favicon.ico"/>';
echo '<LINK REL="stylesheet" href=style.css" type="text/css" />';
echo ' <!--[if IE 6]>
<link rel="stylesheet" href="ie6.css" type="text/css" title="IE6" />
<![endif]-->
';
echo '<script type="text/javascript" src="jv.js"></script>';
echo "<title>$page_title</title>";
// Meta data
echo "<meta name='description' content='$meta_description'/>";
echo "<meta name='keywords' content='$meta_keywords' />";
echo '<meta name="revisit-after" content="1 days" />';
echo '</head>';
}
enjoy!
Bookmarks