Will This Work and were would I put it?

hello all, with the following code work and were would I put it.  Metatags are the same as home page I want them dynamic to content with-in posts and blogs.

 

 <?php

// Open database here...

// SQL
$sql = mysql_query("SELECT * FROM database WHERE id = '" . $id . "' LIMIT 1") or die (mysql_error());

while($row = mysql_fetch_array($sql)){
$title = $row['title']; // get title from database
$description = $row['description']; // get description from database
$keywords = substr($row['keywords'], 0, 250); // get keywords (250 characters) from database
}

// Close database here...
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;
<html>
<head>
<title><?php echo $title?></title>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<meta http-equiv="Content-Language" content="en">
<meta name="description" content="<?php echo $description?>">
<meta name="keywords" content="<?php echo $keywords?>">
</head>
<body>

<!-- HTML content goes here... -->