Err, here is my updated code and edited out some unneeded code!
global_application.php
<?php
// global_application.php
/*---------------------------------------------------------
Debugging
---------------------------------------------------------*/
error_reporting(E_ALL);
/*---------------------------------------------------------
Database class
- connection to database
- database info
---------------------------------------------------------*/
class Db
{
// attributes
var $server = "localhost";
var $database = "jameshu_gardengrove";
var $username = "jameshu_gardengr";
var $password = "spoonful247";
var $dbConnect;
var $dbSelect;
// operations
function connectDb()
{
// connect to server
$this->dbConnect = mysql_connect($this->server, $this->username, $this->password)
or die('Could not connect to server!');
// connect to database
$this->dbSelect = mysql_select_db($this->database, $this->dbConnect)
or die('Could not connect to database!');
}
}
/*---------------------------------------------------------
Config class
- generic
---------------------------------------------------------*/
class Config
{
var $wwwRoot;
var $dirRoot;
var $includesRoot;
var $imagesRoot;
// assigns config info
function config()
{
$this->wwwRoot = ".";
$this->dirRoot = "/home/user_name/public_html";
$this->includesRoot = $this->wwwRoot . "/includes";
$this->imagesRoot = $this->wwwRoot . "/images";
}
}
/*---------------------------------------------------------
Config object
---------------------------------------------------------*/
$cfg = new Config;
/*---------------------------------------------------------
Page class
- displays dynamic and static pages
----------------------------------------------------------*/
class Page extends Config
{
// attributes
var $body;
var $title;
var $keywords = "Garden Grove band, band";
var $currentPage;
var $dbQuery;
var $dbResult;
var $dbResultNum;
var $newsUserId;
var $newsSubject;
var $newsNews;
var $newsTimestamp;
// display the page
function display()
{
?>
<html>
<head>
<?php
$this->displayTitle();
$this->displayKeywords();
$this->displayIncludes();
?>
</head>
<body>
<?php
$this->displayHeader();
$this->displaySectionImage();
?>
<td width="784" height="400"class="body">asd
<?php
echo $this->body;
?>
</td>
</tr>
</table>
<?php
$this->displayFooter();
?>
</body>
</html>
<?php
}
// display title
function displayTitle()
{
// these functions will display appropriate title
// for the respective page
if ($this->currentPage == "news")
{
$this->title = "News";
}
elseif ($this->currentPage == "band")
{
$this->title = "Band";
}
elseif ($this->currentPage == "discography")
{
$this->title = "Discography";
}
elseif ($this->currentPage == "media")
{
$this->title = "Media";
}
elseif ($this->currentPage == "links")
{
$this->title = "Links";
}
// if $this->currentPage is not designated, then the title
// will be whatever is assigned to it exclusively
$this->currentPage = $this->title;
?>
<title>Garden Grove [ <?php echo "$this->title"; ?> ]</title>
<?php
}
// display meta keywords
function displayKeywords()
{
?>
<meta name="keywords" content="<?php echo "$this->keywords"; ?>">
<?php
}
// display includes
function displayIncludes()
{
// pull config() from Config class
parent::config();
?>
<link rel="stylesheet" type="text/css" href="<?php echo "$this->includesRoot"; ?>/gardengrove.css">
<?php
}
// display header
function displayHeader()
{
?>
<map name="logo">
<area shape="rect" coords="432,234,488,256" href=".">
<area shape="rect" coords="490,227,549,254" href="/band/">
<area shape="rect" coords="551,228,669,254" href="/discography/">
<area shape="rect" coords="671,229,738,254" href="/media/">
<area shape="rect" coords="740,227,795,254" href="/links/">
</map>
<table cellspacing="0" cellpadding="0" class="overall" width="800">
<tr>
<td colspan="2"><img src="images/overall_logo.jpg" width="800" usemap="#logo" border="0"></td>
</tr>
<tr>
<?php
}
// display the section image
function displaySectionImage()
{
// changes the image to appropriate
if ($this->currentPage == "News")
{
$this->currentPage = "news";
}
// pull config() from Config class
parent::config();
?>
<td width="16" class="bodyTitle"><img src="<?php echo "$this->imagesRoot/body_$this->currentPage.gif"; ?>" width="15" height="32" class="body"></td>
<?php
}
// display the each imagemap sector for navigation
function displayNav($navName, $navUrl, $navCoord)
{
?>
<area shape="rect" coords="<?php echo "$navCoord"; ?>" href="<?php echo "$navUrl"; ?> alt="<?php echo "$navName"; ?>">
<?php
}
// display footer
function displayFooter()
{
?>
<table cellspacing="0" cellpadding="0" class="footer" width="800">
<tr>
<td><img src="images/overall_footer.jpg" width="800" height="105"></td>
</tr>
</table>
<table cellspacing="0" cellpadding="0" width="800">
<tr>
<td class="copyright">Copyright © 2004 Garden Grove. All rights reserved. <a href="<?php parent::config(); echo "$this->wwwRoot"; ?>/contact/" class="secondary">Contact</a></td>
</tr>
</table>
<?php
}
// specialty page functions
// display news
function displayNews()
{
$this->dbQuery = "SELECT * FROM news WHERE userid = '".$this->newsUserId."'
AND subject = '".$this->newsSubject."' AND news = '".$this->newsNews."'
AND timestamp = '".$this->newsTimestamp."'";
$this->dbResult = mysql_query($this->dbQuery);
$this->dbResultNum = mysql_num_rows($this->dbResult);
// will count how many rows in database and then
// loop display until there are no more to display
while ($dbResultNum = mysql_fetch_assoc($this->dbResult))
{
?>
<span class="newsTitle"><?php echo "$news->newsSubject']"; ?></span>
<br /><span class=\"newsOrigin\"><?php echo "$news->newsUserId"; ?>- $newsDate @ $newsTime</span>
<br /><br /><?php echo "$news->newsNews"; ?></td>
<?php
}
}
}
?>
index.php
<?php
// index.php - news
require('global_application.php');
// database connection
$db = new Db();
$db->dbConnect = NULL;
$db->dbSelect = NULL;
$db->connectDb();
// new Page object
$news = new Page();
// designate what page this is
$news->currentPage = "news";
// what appears in the body
$news->setBody($news->displayNews());
// display what belongs in the page
$news->display();
?>
Thanks for your time!