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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.