Forum Moderators: coopster

Message Too Old, No Replies

Changing page title using PHP

Reading value for page title from database

         

bellrj

5:54 pm on Dec 8, 2002 (gmt 0)

10+ Year Member



I'm trying to write a PHP page that takes the value of the TITLE meta tag from a value in my database. I've got all the database connection stuff working but the problem is that I cannot see how to write the title meta tag code to display the database value. I tried this as a stab in the dark ($page_title is already set before this point):

<head>
<title><?php $page_title?></title>
</head>

Can anyone help me please? I've looked in my book and on Google but can't find any code examples. Thanks.

ikbenhet1

5:56 pm on Dec 8, 2002 (gmt 0)

10+ Year Member



<head>
<title><?php echo $page_title;?></title>
</head>

bellrj

6:03 pm on Dec 8, 2002 (gmt 0)

10+ Year Member



Wow! Quick response! Thank you very much. And it works - cool! :)

I hang my head in shame at forgetting the semi-colon... and the echo was maybe a bit obvious too... Ah well, I'm just learning PHP so I'll forgive myself this time. ;) Thanks again! :)

andreasfriedrich

6:07 pm on Dec 8, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<title><?=$page_title?></title>

would work as well, even without the semi-colon.

Andreas