Using PHP to Create Relevant Title Tags in osCommerce Websites - Proper Page Title Naming for the Product Pages (
Page 4 of 4 )
For the
Product_info.php,
the following is the recommended script:
<?php
$optimizedurl=$_SERVER["REQUEST_URI"];
$location1=(strpos($optimizedurl,'products_id'));
$start= $location1 + 12;
$productidextracted=substr($optimizedurl,$start,2);
$result = mysql_query("SELECT `products_name` FROM `products_description` WHERE `products_id`='$productidextracted'")
or die(mysql_error());
$row = mysql_fetch_array($result)
or die("Invalid query: " . mysql_error());
echo "<br />";
$titletag = $row['products_name'];
?>
<title><?php echo $titletag; ?></title>
To implement the following recommendations, find this piece of code in the default affected templates:
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
Replace it with the modified PHP script. For the
product_info.php
the above lines will now become:
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<?php
$optimizedurl=$_SERVER["REQUEST_URI"];
$location1=(strpos($optimizedurl,'products_id'));
$start= $location1 + 12;
$productidextracted=substr($optimizedurl,$start,2);
$result = mysql_query("SELECT `products_name` FROM `products_description` WHERE `products_id`='$productidextracted'")
or die(mysql_error());
$row = mysql_fetch_array($result)
or die("Invalid query: " . mysql_error());
echo "<br />";
$titletag = $row['products_name'];
?>
<title><?php echo $titletag; ?></title>
To be truly effective, revise the title tag PHP script in all important templates such as index.php, product_info.php, and the main pages in a typical osCommerce website navigation menu.
You can find more osCommerce tips and tricks here:
http://www.php-developer.org/