Did you put it between your <title> elements?
You can do this of course. It simply means restructuring so your processing ends up before your HTML output. Ultimately this is what you should do in PHP anyways.
A really simple example:
Simple as that. Just make sure that you don't output the head and title until after you've retrieved your results.
// Do whatever to get these records. I'll just pretend that I have a function for it.
$record = fetchMaRecord($_GET['id']);
// now $record has what it need, and presumably only one result.
<Doctype. . .>
<title><?php echo $record['name'];?></title>