$php_mysql$ Posted August 20, 2011 Share Posted August 20, 2011 so i set names for every pages, like $pageName = 'home'; //index page if($pageName == 'categories'){ $find = "Birds & Bees"; $result = strpos($title,$find); echo '1'; }else if($pageName == 'categories'){ $find1 = "Money & Honey"; $result = strpos($title,$find1); echo '2'; } now the issue is with categories.php page, which is just one page but displays different title and according to matching title i wish to change the description but its not happening, everywhere only 1 prints, why? Link to comment https://forums.phpfreaks.com/topic/245309-different-meta-description-different-pages/ Share on other sites More sharing options...
voip03 Posted August 20, 2011 Share Posted August 20, 2011 $pageName == 'categories' 1st if statement is always true. Link to comment https://forums.phpfreaks.com/topic/245309-different-meta-description-different-pages/#findComment-1259934 Share on other sites More sharing options...
$php_mysql$ Posted August 20, 2011 Author Share Posted August 20, 2011 sorry i do not get you. its not with the pagename the issue is with matchin titles and change the <meta description accordingly. Link to comment https://forums.phpfreaks.com/topic/245309-different-meta-description-different-pages/#findComment-1259936 Share on other sites More sharing options...
voip03 Posted August 20, 2011 Share Posted August 20, 2011 if($pageName == 'categories') <------ $pageName == 'categories' { $find = "Birds & Bees"; $result = strpos($title,$find); echo '1'; } else if($pageName == 'categories')<---------------- $pageName == 'categories' { $find1 = "Money & Honey"; $result = strpos($title,$find1); echo '2'; } borth IF statement you are checking same variable Link to comment https://forums.phpfreaks.com/topic/245309-different-meta-description-different-pages/#findComment-1259937 Share on other sites More sharing options...
voip03 Posted August 20, 2011 Share Posted August 20, 2011 if($pageName == 'categories-1') { $find = "Birds & Bees"; $result = strpos($title,$find); echo '1'; } else if($pageName == 'categories-2') { $find1 = "Money & Honey"; $result = strpos($title,$find1); echo '2'; } Link to comment https://forums.phpfreaks.com/topic/245309-different-meta-description-different-pages/#findComment-1259938 Share on other sites More sharing options...
$php_mysql$ Posted August 20, 2011 Author Share Posted August 20, 2011 but both the titles 1. Birds & Bees and 2. Money & Honey comes from $pageName == 'categories' so how else can i find these two matching strings in titles ? Link to comment https://forums.phpfreaks.com/topic/245309-different-meta-description-different-pages/#findComment-1259942 Share on other sites More sharing options...
voip03 Posted August 20, 2011 Share Posted August 20, 2011 can u tell me the details of the categories table( field names) Link to comment https://forums.phpfreaks.com/topic/245309-different-meta-description-different-pages/#findComment-1259947 Share on other sites More sharing options...
$php_mysql$ Posted August 20, 2011 Author Share Posted August 20, 2011 well in categories.php i set a name as $pageName = 'categories'; the the links to categories goes like index.php?category=birds_bees or index.php?category=honey_money and i set it in a variable like $title = $_REQUEST['category']; so with every different link the category name changes now i want to match those words which are preset like honey and money or birds and bees and the change page description, what option do i got? Link to comment https://forums.phpfreaks.com/topic/245309-different-meta-description-different-pages/#findComment-1259949 Share on other sites More sharing options...
voip03 Posted August 20, 2011 Share Posted August 20, 2011 <meta name="description" content= "<? echo $title ; ?>." /> Link to comment https://forums.phpfreaks.com/topic/245309-different-meta-description-different-pages/#findComment-1259951 Share on other sites More sharing options...
voip03 Posted August 20, 2011 Share Posted August 20, 2011 <?php $title = $_REQUEST['category']; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta name="description" content= "<? echo $title ; ?>." /> <title>Untitled Document</title> </head> <body> </body> </html> Link to comment https://forums.phpfreaks.com/topic/245309-different-meta-description-different-pages/#findComment-1259953 Share on other sites More sharing options...
$php_mysql$ Posted August 20, 2011 Author Share Posted August 20, 2011 lol no mate not that :-D i want if(name in $title == 'Birds & Bees'){ echo '<meta name="description" content= "Some description for birds and bees." />'; }else if (name in $title == 'Money & Honey'){ echo '<meta name="description" content= "Some description for Money & Honey." />'; }else{ echo '<meta name="description" content= "Default description." />'; } the issue is getting matching names Money & Honey or Birds & Bees from $title Link to comment https://forums.phpfreaks.com/topic/245309-different-meta-description-different-pages/#findComment-1259955 Share on other sites More sharing options...
$php_mysql$ Posted August 20, 2011 Author Share Posted August 20, 2011 ah nevermind thanks soo much bro i got it if $pageName == 'categories' && $title == 'Birds & Bees' :-D really appreciate u giving ur time trying to help me out. Link to comment https://forums.phpfreaks.com/topic/245309-different-meta-description-different-pages/#findComment-1259956 Share on other sites More sharing options...
voip03 Posted August 20, 2011 Share Posted August 20, 2011 I could not understand you query very will. thanks Link to comment https://forums.phpfreaks.com/topic/245309-different-meta-description-different-pages/#findComment-1259961 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.