I am try to add 2 menu on a single page

I can get a left menu working on one page and on other page I can get the top menu working but I can’t get these menus working on a single page.
How do I go about having these menus on same page?

Top menu url
http://www.melbtrip.com/cms07/hello2.php

Left menu
http://www.melbtrip.com/cms07/hello3.php?id=1

Here code for my databases

CREATE TABLE Subjects(
id INT(11) NOT NULL AUTO_INCREMENT,
title VARCHAR(50) NOT NULL,
content TEXT NOT NULL,
PRIMARY KEY(id)
);

CREATE TABLE Pages(
id INT NOT NULL AUTO_INCREMENT,
subjects_id INT(11),
title VARCHAR(50) NOT NULL,
content TEXT NOT NULL,
PRIMARY KEY(id)
);

Top menu code


<?php
include 'database';
include 'database';

// if no id is specified, list the available articles

{
$self = $_SERVERPHP_SELF;

$query = "SELECT id, title FROM Subjects ORDER BY id";
$result = mysql_query($query) or die('Error : ' . mysql_error());

// create the article list
while($row = mysql_fetch_array($result, MYSQL_NUM))
{
list($id, $title) = $row;
$page .= "<a href="$self?id=$id">$titlern";

}


$title = 'Available Articles';
}

if(!isset($_GETid))
{
$query = "SELECT id, title, content ".
"FROM Subjects ".
"WHERE id = '1'";
$result = mysql_query($query) or die('Error : ' . mysql_error());
list($id, $title, $content) = mysql_fetch_array($result, MYSQL_NUM);
}
else{

$query = "SELECT id, title, content ".
"FROM Subjects ".
"WHERE id = '{$_GETid}'";
$result = mysql_query($query) or die('Error : ' . mysql_error());
list($id, $title, $content) = mysql_fetch_array($result, MYSQL_NUM);
}

include ' close database';

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/x­ html1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtm­ l" lang="EN" xml:lang="EN">
<head>
<link rel="stylesheet" href="css/main.css" type="text/css" />
<title>Allan Close</title>
</head>
<div id="header">
<div id="sitename">
<h1>Matthew Close </h1>
<h2>www.matthewclose.com.au<­ /h2>
</div>
</div>
<div id="mainNav">
<ul>
<li id="home"><?php echo $page;
// when displaying an article show a link
// to see the article list
?></li>
</ul>
</div>
<div id="left">
<?php
echo $page1;

// when displaying an article show a link
// to see the article list

?>
</div>
<div id="centre1">
<?php
echo $content;

// when displaying an article show a link
// to see the article list

?>
<br />
<br />
<br />

</div>
<div id="footer"> By matthew close</div>
</body>
</html>



left Menu



<?php
include 'library/config.php';
include 'library/opendb.php';

{
$self = $_SERVERPHP_SELF;

$query = "SELECT id, title FROM Pages ORDER BY id";
$result = mysql_query($query) or die('Error : ' . mysql_error());

// create the article list
while($row = mysql_fetch_array($result, MYSQL_NUM))
{
list($id, $title) = $row;
$page1 .= "<a href="$self?id=$id">$titlern";

}


$title = 'Available Articles';
}


$query = "SELECT id, title, content ".
"FROM Pages ".
"WHERE id = '{$_GETid}'";
$result = mysql_query($query) or die('Error : ' . mysql_error());
list($id, $title, $content) = mysql_fetch_array($result, MYSQL_NUM);

include ' close database';
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/x­ html1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtm­ l" lang="EN" xml:lang="EN">
<head>
<link rel="stylesheet" href="css/main.css" type="text/css" />
<title>Allan Close</title>
</head>
<div id="header">
<div id="sitename">
<h1>Matthew Close </h1>
<h2>www.matthewclose.com.au<­ /h2>
</div>
</div>
<div id="mainNav">
<ul>
<li id="home"></li>
</ul>
</div>
<div id="left">
<?php
echo $page1;

// when displaying an article show a link
// to see the article list

?>
</div>
<div id="centre1">
<?php
echo $content;

// when displaying an article show a link
// to see the article list

?>
<br />
<br />
<br />

</div>
<div id="footer"> By matthew close</div>
</body>
</html>

Thank you

from Matthew

Can’t you just include either in the appropriate places?

I can get two menus working on the same page but I can’t get the mysql to work so that only displays left menu when equals to Subject ID.
page can be located here http://www.melbtrip.com/cms07/index.php

the error is when clicking on hello world which id = 1 still displays
cats in left hand menu
I think I have work out my problem and the problem is with my MYSQL statement


function get_pages_for_subject($subject_id)­ {
global $connection;
$query = "SELECT *
FROM pages
WHERE subject_id = {$subject_id}
ORDER BY position ASC";
$page_set = mysql_query($query, $connection);
confirm_query($page_set);
return $page_set;
}

functions.php


<?php


function confirm_query($result_set) {
if (!$result_set) {
die("Database query failed: " . mysql_error());
}
}

function get_all_subjects() {
global $connection;
$query = "SELECT *
FROM subjects
ORDER BY position ASC";
$subject_set = mysql_query($query, $connection);
confirm_query($subject_set);
return $subject_set;
}

function get_pages_for_subject($subject_id)­ {
global $connection;
$query = "SELECT *
FROM pages
WHERE subject_id = {$subject_id}
ORDER BY position ASC";
$page_set = mysql_query($query, $connection);
confirm_query($page_set);
return $page_set;
}
?>



index.php


<?php require_once("connects to database"); ?>

<?php require_once("connects to functions.php"); ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/x­ html1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">­
<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<link href="css/main.css" rel="stylesheet" type="text/css" />
</head>

<body>
<div id="header"> </div>
<div id="mainNav">

<ul>
<?php
$subject_set = get_all_subjects();
while ($subject = mysql_fetch_array($subject_set)) {
echo "<li>";
if ($subjectid == $sel_subj) { }
echo "<a href="index.php?subj=" . urlencode($subjectid) .
"">{$subjectmenu_name}</li>";
}
?>
</ul>
</div>
<div id="left">
<div id="sectionLinks">
<?php
$subject_set = get_all_subjects();
while ($subject = mysql_fetch_array($subject_set)) {

$page_set = get_pages_for_subject($subjectid);

while ($page = mysql_fetch_array($page_set)) {
echo "<li";
if ($pageid == $sel_page) { echo " class="selected""; }
echo "><a href="index.php?page=" . urlencode($pageid) .
"">{$pagemenu_name}</li>";
}
}

?>
</div>
</div>
<div id="content"><br />
<?php echo $sel_subj; ?><br />
<?php echo $sel_page; ?><br />


<br />
<br />
<br />

</div>
<div id="footer"> </div>
</body>
</html>


thank you

matthew

Sponsor our Newsletter | Privacy Policy | Terms of Service