0

I'm trying to find a way of automatically updating page titles on my site - occasionally, connections (owners, trainers, jockeys of horses) will appear as a variation of their original name (i.e. Mr M Smith may pop up as Mr Matt Smith). I update these in the database, but the page titles are hard coded, so they generally remain in their original format until I find time to tweak them.

I understand that there is a way in which the page title/meta data can be pulled from a database, but I'm struggling to find tutorials to describe what I'm looking for. I've tried using a tuotrial below, but am just resulting in a blank white page. I wondered if someone could point me in the right direction, please?

Head.php include:

<!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 http-equiv="Content-type" content="text/html; charset=utf-8" />
<title><?php
if (isset($pageTitle)) {
echo $pageTitle;
} else {
echo "ARF Data";
}
?></title>
</head>

samplehorse.php

<?php include($_SERVER['DOCUMENT_ROOT'].'/*****/******.php');?>  <-- db connection -->

<?php
$sql = "SELECT horse, h_ctry
FROM `horse` WHERE h_link = '00001.php'
LIMIT 1";
$result = mysqli_query($sql) or die(mysql_error());
$row = mysqli_fetch_assoc($result);

$pageTitle = $row['horse'];
include("/testing/dynamicheaders/head.php");

Any advice much appreciated.

3
Contributors
2
Replies
17
Views
3 Years
Discussion Span
Last Post by jsuna
0

As @zagga suggested, put your code in the body to see it on the page, otherwise you won't see anything on the page... look at the browser tab to see your changes in the <title> element. cheers!

Edited by jsuna

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.