Forum Moderators: coopster

Message Too Old, No Replies

Dynamic Title issues > Help please!

Problems including dynamic titles

         

thinkthinker

8:05 pm on Oct 3, 2007 (gmt 0)

10+ Year Member



Here is my problem: First, I am talking about two files. page.php which serves as the main content page and header.php which contains the obvious header information.

page.php contains the code listed below. I am I am trying to get the <title></title> tag to echo the headline which is described below. The only way of doing this that I have found is copying all of the data below into the head file and placing the <?php echo "?> data into the <title> </title> tags.

That works like a charm! The only problem is I am running into duplicate scripts running which then causes the body (page.php) not to show up. Dynamic titles work fine. Any ideas? Suggestions? Help! Thanks.

<?php
if (!isset($_REQUEST['page'])&&!isset($_REQUEST['story']))
{
header('Location: index.php');
exit;
}

$page = $_REQUEST['page'];
$story = intval($_REQUEST['story']);

include_once('db_fns.php');
include_once('header.php');

$handle = db_connect();
if($story)
{
$query = "select * from stories
where id = '$story' and
published is not null";
}
else
{
$query = "select * from stories
where page = '$page' and
published is not null
order by published desc";
}
$result = $handle->query($query);

while ($story = $result->fetch_assoc())
{
// title
$title = 'Hello!';
// headline
$id = $story['id'];
echo "<a href='page.php?story=$id'><h2>{$story['headline']}</h2></a>";
//picture
if ($story['picture'])
{
echo '<div style="float:right; margin:0px 0px 6px 6px;">';
echo '<img src="resize_image.php?image=';
echo urlencode($story[picture]);
echo '&max_width=200&max_height=120" align = right/></div>';
}
// byline
$w = get_writer_record($story['writer']);
echo '<br /><p class="byline">';
echo $w[full_name].', ';
echo date('M d, H:i', $story['modified']);
echo '</p>';
// main text
echo $story['story_text'];
}
include_once('footer.php');
?>

jbroder

11:46 pm on Oct 3, 2007 (gmt 0)

10+ Year Member



how about this?

edit header.php: <title><?=$headline?></title>

include header.php after $headline is set

Hope that helps.

Jon