I have a classified ad script, and when someone views an ad I would like the title to also be in the title of the site. (Like when I post this, the title is "PHPBuilder.com - Post New Thread").
I have been working on this for an hour an can't figure it out.
Here's the page where the ad is shown:
<?php
include('header.php');
//If $_GET['ad'] isn't set...
if(!isset($_GET['ad']) || $_GET['ad'] == '')
echo 'No ad exists with this ID. Please try again.'; //Print the error and stop.
//Otherwise...
else
{
//Load Ad data
$ad = new CAd($sql);
$ad->LoadAd($_GET['ad']);
$ad->LoadOwner();
$_GET['cat'] = $ad->category; //Set $_GET['cat'] for featured.php
//Output the table that gives the Ad's category, and the option of returning to category view
echo '<table width="515px" align="center"><tr><td class="category-box"><img src="images/dot.gif" valign="center" /> '.$ad->category_name.' <font color="black"><a href="show_ads.php?cat='.$ad->category.'">Click for more ads in the category</a></font></td></tr></table>';
//Output the ad itself
echo $ad->OutputFullAd();
}
require('footer.php');
?>
Here's header.php (Where the <title></title> tags are):
<?php
session_start();
$includes = array('config.php', 'CSQL.php', 'CAd.php', 'CUser.php', 'CCategory.php', 'misc_functions.php');
foreach($includes as $include)
require_once($include);
kill_mq();
$sql = new CSQL(DB_NAME, DB_USER, DB_PASS, DB_HOST);
$user = new CUser($sql);
if(!isset($_SESSION['username']) && isset($_COOKIE['uid']))
{
$query = mysql_query("SELECT name FROM users WHERE ID = '".$_COOKIE['uid']."' AND password = '".$_COOKIE['sess_hash']."'");
if(mysql_num_rows($query) == 1)
$_SESSION['username'] = mysql_result($query, 0);
}
if(isset($_GET['logout']))
{
setcookie('uid', false, time()-3600, '/', '.racingrides.com');
setcookie('sess_hash', false, time()-3600, '/', '.racingrides.com');
unset($_SESSION['username']);
}
if(isset($_SESSION['username']) && $_SESSION['username'] != '')
$user->ForceLogin($_SESSION['username']);
if(isset($_POST['login']) || isset($_POST['login_x']))
{
if(!$user->Login($_POST['user'], $_POST['password']))
echo '<script language="JavaScript">alert("Error: Incorrect username/password.");</script>';
else
{
setcookie('uid', $user->ID, time()+60*60*24*30, '/', '.');
setcookie('sess_hash', $user->password, time()+60*60*24*30, '/', '.racingrides.com');
}
}
?>
<!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>
<link href="main.css" type="text/css" rel="stylesheet">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>My Site- <?php $title ?> ! </title>
</head>
<body align="center">
<center>
<table style="width:766px;background:#FFFFFF;" border="0" cellspacing="0" cellpadding="0">
<tbody><tr>
<td colspan="2">
<table style="width:766px;" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" style="width:284px;"><a href="index.php"><img src="images/logo.gif" width="284" height="111" alt="" border="0"/></a></td>
<td valign="top">
<table style="background:url(images/top-bg.gif); width:482px;" border="0" cellspacing="0" cellpadding="0">
<tr>
<td style="height:2px;"> </td>
</tr>
<tr>
</td>
</tr>
<tr>
<td valign="top" style="width:284px;background:#FFFFFF;"> </td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2">
<table id="Top-Menu" style="width:766px; height:36px;background:#FFFFFF;" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<a href="index.php"><img src="images/home.gif" alt="" width="109" height="36" border="0" /></a></td>
<td>
<td>
<a href="index.php"><img src="images/browse.gif" alt="" width="110" height="36" border="0" /></a></td>
<td>
<a href="adshow.php?order=newest"><img src="images/newest.gif" alt="" width="102" height="36" border="0" /></a></td>
<td>
<a href="adshow.php?order=hottest"><img src="images/hottest.gif" alt="" width="104" height="36" border="0" /></a></td>
<td>
<a href="help.php"><img src="images/help.gif" alt="" width="124" height="36" border="0" /></a></td>
<td>
<a href="contactus.php"><img src="images/contact.gif" alt="" width="131" height="36" border="0" /></a></td>
<td>
<img src="images/forum.gif" alt="" width="86" height="36" border="0" /></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<tr>
<td align="left" valign="top" style="width:243px; background:#FFFFFF;">
<table style="width:243px;background:url(images/bg-left.gif);" border="0" cellspacing="0" cellpadding="5">
<tr><td><center>
<img src="images/login.gif" /><br>
<br><?php echo $user->OutputLogin(); ?>
</center></td></tr></table>
<table style="width:243px;background:url(images/bg-left.gif);" border="0" cellspacing="0" cellpadding="1">
<tr>
<td align="center" valign="top"><img src="images/sponsors.gif" width="229" height="31" alt="" /></td>
</tr>
<tr>
<td align="center" valign="top" style="padding-top:10px; padding-bottom:10px;">
</td>
</tr>
<tr>
<td align="center" valign="top"><img src="images/newletter.gif" width="229" height="30" alt="" border="0"/><br><br></td>
</tr>
</table>
<table style="width:243px;background:url(images/bg-left.gif);" border="0" cellspacing="0" cellpadding="1">
<tr>
<td align="center" valign="top"><a href="contactus.php"><img src="images/contactus.gif" border="0"></a></td>
</tr>
<tr>
<td align="center" valign="top"> </td>
</tr>
</table>
</td>
<td align="left" valign="top" style="width:523px; margin: 5px;background:#FFFFFF;">
<img src="images/3spacer.gif">
Any help is appreciated! Thanks! 🙂