Site Cloner PHP Script
Bargain Hunter PHP Script
Job Hunter PHP Script
Site Login and Access Control PHP Script

Making Dynamic Page Titles with PHP

You can use the variable $page_title in the head of the header.<title><?php echo $page_title; ?> </title>

//get the url of the page with the curl() function
$my_url=curl();

//get the route
$findme   = ‘mysite.com/category/subcategory’;
//make sure the path is in the url
$pos = strpos($my_url, $findme);
//echo $pos;
if ($pos==true){
//echo $my_url;
//just grab the unique id of the article
$my_url_trimmed = str_replace(“http://www.mysite.com/category/subcategory/”, “”, $my_url);
//echo $my_url_trimmed;
//query the database and find the data you want for the page title
$command = “SELECT tb1.id, tb1.col1, tb1.col2 from tablename as tb1 WHERE tb1.id=’$my_url_trimmed’;”;
$result = mysqli_query($db, $command);
if ($result && mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)) {
//make the new page title
$space=” “;
$gap=” | “;
$location=$row[“col1”];
$page_title= $row[“col2”].$space.$location.$gap;

}

}
}