Jump to content

Adding Keywords and Metatags


fusionpixel

Recommended Posts

Here is a little something that I use:

<?php 
$page = $_SERVER['PHP_SELF'];
$page = str_replace('/', '', $page);

include "connect.php";

//Find the meta data
$sql = mysql_query("SELECT * FROM meta_data WHERE page = \"$page\"") or die('Query failed: ' . mysql_error());
$count = mysql_num_rows($sql);

if($count > 0){
	$page_title = mysql_result($sql, 0, 'title');
	$keywords = mysql_result($sql, 0, 'keywords');
	$description = mysql_result($sql, 0, 'description');
	$page_title = stripslashes($page_title);
	$keywords = stripslashes($keywords);
	$description = stripslashes($description);

	if(strlen($page_title) > 0){
		$page_title .= " ";
	}

}else{
	$sql = mysql_query("SELECT * FROM meta_data WHERE page = \"default.php\"") or die('Query failed: ' . mysql_error());
	$page_title = mysql_result($sql, 0, 'title');
	$keywords = mysql_result($sql, 0, 'keywords');
	$description = mysql_result($sql, 0, 'description');
	$page_title = stripslashes($page_title);
	$keywords = stripslashes($keywords);
	$description = stripslashes($description);
}
?>  

 

it just pulls the metadata from the DB for the page specified (if I put something into the DB). Then I just echo it in the html where it needs to go

 

hope this helps.

Link to comment
Share on other sites

To any visitor, robot, spider or genuine user, the data they receive from a page is the same. If you include it or echo it or if it's just html, the browser doesnt know any different. So dont worry, search engines will still see your keywords and descriptions.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.