HI
Dynamic page title (product description)
I am trying to set my page title to reflect product description when I view the product page. Product info is sourced from MySql database.
The website do have pages like (about us, contact us, terms and condition, links etc) but in this case I need change for the products that are pulled from database.
The line that pulls description = <div class="block-yellow"><h5 class="padding-5"><?php echo $Pagedescr?></h5></div>
I’ve tried to but $pagedescr in my code but it doesn’t work.
<title><?php
if (isset($pageTitle)) {
echo $pagedescr;
} else {
echo "Name of the company";
}
?></title>
This is how the page is called: http://company.com/?page=Product&id=77
Please help, I’ve got no much experience in PHP.
Thanks
Dynamic page title (product description)
Moderator: General Moderators
Re: Dynamic page title (product description)
Well we would need to see more of your code... What sets $pageTitle? what is its relationship to $pagedescr that you are echoing based on it? Are the variables named the exact way you have them? $Pagedesc and $pagedescr are two separate variables in PHP.
-Greg
-Greg
Re: Dynamic page title (product description)
HI Twinedev, sorry made a mistake there;
Corrected code is: title><?php
if (isset($pagedescr)) {
echo $pagedescr;
} else {
echo "Name of the company";
}
?></title>
$Pagedescr = Page description - this gets the product description from database
Corrected code is: title><?php
if (isset($pagedescr)) {
echo $pagedescr;
} else {
echo "Name of the company";
}
?></title>
$Pagedescr = Page description - this gets the product description from database
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: Dynamic page title (product description)
Code: Select all
<title>
<?php echo (isset($pagedescr)) ? $pagedescr : 'Name of company'; ?>
</title>Also, this still isn't how you retrieve the data from the database, retrieval should be something using a SQL query;mlungisi wrote:$Pagedescr = Page description - this gets the product description from database
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Re: Dynamic page title (product description)
Query
if($item_count==1){
$Pagedescr = $data['ItemId'].': '.$data['ItemName'];
}elseif($data['GroupView']==3){
$Pagedescr = 'Product Group: '.$data['Group'];
}
if($item_count==1){
$Pagedescr = $data['ItemId'].': '.$data['ItemName'];
}elseif($data['GroupView']==3){
$Pagedescr = 'Product Group: '.$data['Group'];
}
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: Dynamic page title (product description)
Code: Select all
<?php
if($item_count==1){
$Pagedescr = $data['ItemId'].': '.$data['ItemName'];
}elseif($data['GroupView']==3){
$Pagedescr = 'Product Group: '.$data['Group'];
}
// is there an else statement below this?
?>“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Re: Dynamic page title (product description)
HI, i'm back from Easter holiday and hope you had a safe break.
The website is http://www.radiant.co.za
Product view: http://www.radiant.co.za/?page=Product&id=JH108&group=
I want to show the name of the product on title. Product name = JH108: Chandelier 240v - Tellus 3-light bar
Also this will help when users share the product page on social network, the product name will be automatically posted.
The product name/description is pulled from MySQL by <?php echo $Pagedescr?> and that's what i want to put in the site title.
The website is http://www.radiant.co.za
Product view: http://www.radiant.co.za/?page=Product&id=JH108&group=
I want to show the name of the product on title. Product name = JH108: Chandelier 240v - Tellus 3-light bar
Also this will help when users share the product page on social network, the product name will be automatically posted.
The product name/description is pulled from MySQL by <?php echo $Pagedescr?> and that's what i want to put in the site title.