Page 1 of 1
internal php navigation
Posted: Mon Oct 20, 2003 4:06 am
by diamondazza
i have my index page set up with the menu like this:
<?
switch ($page) {
case "guide":
include('guide/guide.inc');
break;
case "bands":
include('db/index.php');
break;
case "ticks":
include('ticks/ticks.php');
break;
case "chat":
include('bands/bands.php');
break;
default:
include('content.php');
}
?>
when i click on "guide" it loads guide.inc into the browser within the index page, bit like a iframe tag, now on the guide.inc page i have another seperate menu. my prob is this, when i click on a menu item in the guide.inc page the index page defualts back to the content.php, i want it to be able to load it within the index page.
-------------------
guide.inc
search || whatshot || lastweek || <------guide.inc menu
-------------------
the links are set up like this:
a href="index.php?page=search.php">search
a href="index.php?page=hot.php">whatshot
etc etc...
basically i want it to act a bit like the iframe tag
i hope this makes sence..please help!
thanx.
Posted: Mon Oct 20, 2003 4:34 am
by Gen-ik
Use a _session to store which page there user is on.
Here is an example.......
Code: Select all
<?
if(!isset($_SESSION["page"]))
{
//set's up the page var in the _session if
//it hasn't been done already.
$_SESSION["page"] = "content"
}
if(isset($_GET["page"]))
{
//checks if someone wants to move to another
//page from the main menu and changes the
//_session var if they do.
$_SESSION["page"] = $_GET["page"];
}
?>
<html>
<body>
<a href="index.php?page=guide>Guide</a>
<a href="index.php?page=bands>Bands</a>
<a href="index.php?page=ticks>Ticks</a>
<a href="index.php?page=chat>Chat</a>
<a href="index.php?page=content>Content</a>
<?
switch ($_SESSION["page"]) {
case "guide":
include('guide/guide.inc');
break;
case "bands":
include('db/index.php');
break;
case "ticks":
include('ticks/ticks.php');
break;
case "chat":
include('bands/bands.php');
break;
default:
include('content.php');
}
?>
</body>
</html>
newbie
Posted: Mon Oct 20, 2003 4:48 am
by diamondazza
i messed about a bit but got a parse error...im a new cumer to this php thing but have some understanding of it. anyways all i got was
a parse error on line 8 which is
==>
Code: Select all
<?php
<?
if(!isset($_SESSION["page"]))
{
//set's up the page var in the _session if
//it hasn't been done already.
$_SESSION["page"] = "content"
} //----this line right here
if(isset($_GET["page"]))
{
//checks if someone wants to move to another
//page from the main menu and changes the
//_session var if they do.
$_SESSION["page"] = $_GET["page"];
}
?>
this has been givin me the <span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span> all week im thinkin about just using the iframe tag instead but ive been told its a simple setup so what am i doing wrong?thanx in advance ey!@
?>
Posted: Mon Oct 20, 2003 5:41 am
by volka
forgot a ; after
Are those two php tag openings at the beginning of the code snippet really in your code?
riiiight..well...um
Posted: Mon Oct 20, 2003 6:12 am
by diamondazza
well the page is loading and i click on the guide link and the guide page is loaded into the middle of my designed page, the guide page has links on it but when i click on one of them the index page just reloads the default content. i have applied the code properly am i missing something?
this is the guide.php page
----------------------------------------
<?php
$navlist = array (
"names" => array("home", "find", "sales", "services", "support", "about"),
"url" => array("/index.php", "index.php?page=guide/find.html", "/sales.html", "/services.html", "/support.html", "/about.html")
);
if ($argc != 0)
{
$uriarray = explode("?", $REQUEST_URI);
$REQUEST_URI = $uriarray[0];
}
$navcount = sizeof($navlist[names]);
for ($i = 0; $i < $navcount; $i++)
{
if ($REQUEST_URI != $navlist[url][$i])
{
echo ("» <a class=\"services\" href=\"");
echo ($navlist[url][$i]);
echo ("\">");
echo ($navlist[names][$i]);
echo ("</a> ");
}
}
?>
-----------------------------
does it matter that the guide.php is stored in a folder or should it be the the same page as the index php page?
--------if its all confusing ill up loasd it to my server and you can have a look for yaswelf if ya want...i really do appreciate all this help.THaNx!!
oh...
Posted: Mon Oct 20, 2003 6:39 am
by diamondazza
heres is the web page link :
http://www.modnet.com.au/~aaron/gmc/index.php
click on gig-guide then click on "find".....SEEE! it loads the defualt page when i want the links to load in that place!!![/url]
Posted: Mon Oct 20, 2003 7:47 am
by volka
It's a bit strange anyway. Why do you parse the request string by yourself? php already did it for you when the script runs.
index.php?page=guide/find.html => $_GET['page'] == 'guide/find.html'
if you make $navlist a one-dimensional list using both keys and values to store your information all you have to do is to test wether $_GET['page'] is set and its value is a key in $navlist. Then remove that element from the array and print out the remaining elements.
(of course there are other ways, its just an example)
aarrgghhh
Posted: Mon Oct 20, 2003 8:01 am
by diamondazza
its driving me nuts!!!!!! the above code is just an example basically i want all links when clicked on too load in the middle of the page between the header, menu and footer. i have already set the main side menu to do this. but when any links that are click on in the content area they load the defualrt content instead
http://www.modnet.com.au/~aaron/gmc/index.php
check it out for yaself.. click gig-guide then find...it should load another page in the same area called find.html but it loads default content.php
which is the index page!??
??????????????????????????????????????????????????????????????????????
it should be simple but its got me stumped![/url]