If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Enjoy an ad free experience by logging in. Not a member yet? Register.

PHP Titles?

Hi all,

I have a page, where named example.php?id=5 then the code will retrieve the rows from id 5, which then the rest of the code puts them out. For example, id 5 may be the person John and then id 4 may be Jane.

The mysql retrieving works when i try to display the info. However, is it possible to use these to set my <title></title>?
I've tried many ways,

PHP Code:

<?php echo htmlspecialchars($retrieverow, ENT_QUOTES, 'utf-8');?>

where $retrieverow was set at the bottom of the page(someone told me so) and others like $_GET. However, the title still remained blank.

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:

PHP Code:

<?php

// 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. . .><html> <head> <title><?php echo $record['name'];?></title> </head> <body>....

Simple as that. Just make sure that you don't output the head and title until after you've retrieved your results.

PHP Code:

header('HTTP/1.1 420 Enhance Your Calm');

Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

Yes, I have put it between <title>. However, it still doesn't work.
I've tried something similar to your suggestions before. However, nothing still appears. Does it matter of I am using PDO to connect to the database?