Browser Title=Data Result?
Posted: Tue Sep 27, 2005 7:37 pm
I have been trying to figure out how to get the <title></title>
to reflect stuff thats pulled from the mysql database and displayed on page.
I figured the <title> needs a variable, but how do you get a variable to get and pass info
to the <title>from a random item shown on page from a database result?
Example of a data result and what I would like to get shown on <title></title>
The above is my code to display the last 10 entries, but will work as an example
of how to grab the News Title and display the text of it on the Browser Title
Where the following is what grabs the Title Info then links it to the comment page, this would be
what I want to get the <title></title> to show.
to reflect stuff thats pulled from the mysql database and displayed on page.
I figured the <title> needs a variable, but how do you get a variable to get and pass info
to the <title>from a random item shown on page from a database result?
Example of a data result and what I would like to get shown on <title></title>
Code: Select all
function show_last_five_entries($url) {
$bash = 1;
$max_results = 10;
$from = (($bash * $max_results) - $max_results);
$sql = mysql_query("SELECT * FROM news ORDER BY date DESC LIMIT $from, $max_results");
$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM news"),0);
$total_bashs = ceil($total_results / $max_results);
$newsbox1 = "<div id=showindexnewsrowtwo class=bordright>";
$newsbox2 = "<div id=showindexnewsrowone>";
$row_count = 0;
while ($row = mysql_fetch_assoc($sql))
{
$row_color = ($row_count % 2) ? $newsbox1 : $newsbox2;
echo "<tr><td>$row_color";
$bash = $row['id'];
/* get number of comments */
$comment_query = "SELECT count(*) FROM comments WHERE newsid='$bash'";
$comment_result = mysql_query ($comment_query);
$comment_row = mysql_fetch_row($comment_result);
$newposts = array ( "<div id=showindexnewstitle><a href=$url/comment/bash/$bash>" => $row['lova'], "</a></div>Submitted By" => $row['name'], "<br /><a href=$url/comment/bash/$bash>$comment_row[0] Comments</a> <a href=$url/tell/bash/$bash>Tell-A-Friend</a><br /><br />" => $row['news'] );
foreach ( $newposts as $postfield => $postinput )
{
$postinput = submitTags($postinput, 1, 1);
echo "<b>{$postfield}</b> {$postinput} ";
}
echo "<br><br></td></tr></div></div>";
$row_count++;
}
}of how to grab the News Title and display the text of it on the Browser Title
Where the following is what grabs the Title Info then links it to the comment page, this would be
what I want to get the <title></title> to show.
Code: Select all
$newposts = array ( "<div id=showindexnewstitle><a href=$url/comment/bash/$bash>" => $row['lova'], "</a></div>