Jump to content

Dynamic SEO tags


graham23s

Recommended Posts

Hi Guys,

 

I can't seem to get this part bit of code right, i'm doing SEO and i am changing the <title></title> tags according to page.

 

code:

 

<?php
$q = mysql_query("SELECT `product_name` FROM `fcs_products` WHERE `id`=".$_GET['id']."");
$r = mysql_fetch_array($q);
$productName = $r['product_name'];

$q1 = mysql_query("SELECT `category_name` FROM `fcs_categories` WHERE `id`=".$_GET['cat-id']."");
$r1 = mysql_fetch_array($q1);
$catName = $r1['category_name'];

if (isset($_GET['cat-id']))
{

     $title  = (isset($_GET['cat-id'])) ? "$catName" : "";
     //$desc   = (isset($_GET['cat-id'])) ? "$catName" : "";

} elseif (isset($_GET['id'])) {

     $title  = (isset($_GET['id']))     ? "$productName" : "eBooks Store | Business eBooks | Marketing eBooks | Training Videos";
     $desc   = (isset($_GET['id']))     ? "$productName" : "the biggest selection of healthcare and software digital downloads";

} else {

     $title  = (isset($_GET['id']))     ? "eBooks Store | Business eBooks | Marketing eBooks | Training Videos" : "";
     $desc   = (isset($_GET['id']))     ? "" : "";
     
}
?>
<title><?php print $title; ?></title>

 

What i'm trying to do is if you on the category page $_GET['cat-id'] it displays the category name in the title tags , if your on the product page $_GET['id'] it displays both of those fine, the problem is if your not on the category or product page i just wanted it to display the default title tags by the looks of the code it should work but it doesn't show the default title tags in your on the index page.

 

have i overcomplicated it by any chance :)

 

cheers guys

 

Graham

Link to comment
https://forums.phpfreaks.com/topic/196283-dynamic-seo-tags/
Share on other sites

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.