Jump to content

how to have a different page title for each page of site using php


autofocus

Recommended Posts

Hi

i was trying to use

define($title, 'title of this page');

and then in title as follow

<title><?=$title;?></title>

 

i have separated header, content and footer and calling header and footer in each page.

 

i have different content on each page. so i wanted title relevant to content.

 

i did not get any error but script stopped after loading header.

 

i think it is easy to achieve but i have no idea at this time. please help.

thanks

 

 

Link to comment
Share on other sites

This data probably also comes from a db? Then why not store the title in it also?

 

<?php
...
$result = mysql_query($query, $db);
extract(mysql_fetch_assoc($result));
?>
<!DOCTYPE html>
<html>
<head>
    <title><?php print $title; ?></title>
</head>
<body>
    <div id="wrapper">
        <div id="content"><?php print $content; ?></div>
        ..
</body>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.