I need some help in generating dynamic web Title pages, based on what action the user has taken. The code below is what I include at the top of all pages… $title changes according to the page I’m calling it from.
<?php
$title = "Biographies of Company Executives";
require('includes/header.php');
?>
But, somewhere down the page, I’m running a DB query to get the actual position of the Company Executive that the user has clicked to view
Example of Query I’m running
$bios = mysql_query( "SELECT *
FROM `comp_bios`
WHERE `comp_bios_id` = '{$id}'") or die(mysql_error());
$row = mysql_fetch_array($bios);
From the above query
$row[comp_bios_position]
is available to the page for usage.
How can I make $row[comp_bios_position] available to $title in the head section of my HTML
Thank you.
I saw this SO question, before asking mine. It didn’t answer the my question as I would have loved.
UPDATE: I added this to the header.php script, and still not working. No error is showing on the screen.
<title>
<?php if(isset($row['comp_bios_position'])) {
$title = $row['comp_bios_position'];}
echo $title;
?>
</title>
My answer in the comment is still valid, put the select part above the
require:And you will have the
$titlein theheader.php