graham23s Posted March 23, 2010 Share Posted March 23, 2010 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 More sharing options...
JAY6390 Posted March 23, 2010 Share Posted March 23, 2010 Change the code for the else { section with the title to read $title = "eBooks Store | Business eBooks | Marketing eBooks | Training Videos"; Link to comment https://forums.phpfreaks.com/topic/196283-dynamic-seo-tags/#findComment-1030737 Share on other sites More sharing options...
graham23s Posted March 23, 2010 Author Share Posted March 23, 2010 ah thanks jay perfect Graham Link to comment https://forums.phpfreaks.com/topic/196283-dynamic-seo-tags/#findComment-1030740 Share on other sites More sharing options...
JAY6390 Posted March 23, 2010 Share Posted March 23, 2010 No problem Link to comment https://forums.phpfreaks.com/topic/196283-dynamic-seo-tags/#findComment-1030742 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.