Hello, all;
I am practising on this blog setup, and I am trying to echo each blog entry's headline appear as the page's Title tag... somehow the way I have it doesnt do it. So that you have an idea of what I am doing, I have an "if" statement in head section that will select "all" records, unless a unique post's id is passed with $post variable, like "?b=101"; in page body then I have another "if" statement that again does "if $post variable is NOT present, it will either show all posts with just first paragraph teaser, else show complete individual article, with paragraph breaks"...
This all seems to be working pretty well, but then when I tried to echo an entry's headline as the page's "Title" tag, I figured I needed to do another if statement with another "while" loop, wich did work and would echo each's individual blog's headline as page "title", but then it prevented the actual blog-entry itself from showing in body section...
I just left it simply as you see in code below for now. I am thinking maybe I can't repeat the "while($row = mysql_fetch_array ($result))" command line twice within same page? or maybe it doesnt pick up the title cause it's calling the "Title" tag variable before the while loop in the body?? I guess there must be something that makes sense logically...
well, appreciate any help and thanks in advance!
<?php include_once ('definitions.php'); ?>
<?php
mysql_select_db ("database_name",$con);
$post = $_GET['b'];
if (!isset($post)) {
$result = mysql_query ("SELECT * from blog ORDER BY blog_id DESC");
$page_title = "Welcome to my Blog!";
} else {
$result = mysql_query ("SELECT * from blog WHERE blog_id = $post");
$page_title = $row['blog_title'];
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title><?php echo $page_title; ?></title>
<link href="styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="wrapper">
<div id="header">
<?php include('header.php'); ?>
</div>
<div id="leftColumn">Content for id "leftColumn" Goes Here </div>
<div id="main">
<table><tr><td>
<?php
if (!isset($post)) {
while($row = mysql_fetch_array ($result)) {
echo "<h1>" . $row['blog_id'] . "-" . "<a href='?b=" . $row['blog_id'] . "'>" . $row['blog_title'] . "</a> </h1><br>" .
substr ($row['blog_body'],0,strpos($row['blog_body'], "\n")). "<br><br>";
}
} else {
while($row = mysql_fetch_array ($result)) {
echo "<h1>" . $row['blog_id'] . "-" . "<a href='?b=" . $row['blog_id'] . "'>" . $row['blog_title'] . "</a> </h1><br>" . nl2br ($row['blog_body']) . "<br><br>";
}
}
?>
</td></tr></table>
</div>
</div>
</body>
</html>
<?php
mysql_close($con);
?>