FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


how to make a php nav





NG
Step 1
The main code:

Code:
<?php
switch ($HTTP_GET_VARS[id]) {
//Default - case
default:
include "news/news.php";
break;

//Fonts - case
case 'resources=fonts':
include 'resources/fonts.php';
break;

//Scripts - case
case 'resources=scripts':
include 'resources/scripts.php';
break;
}
?>


Step 2
So first of all lets break the code down.

<?php
switch ($HTTP_GET_VARS[id]) {
First off <?php is required to notify that you want php coding to start.
Second of all $HTTP_GET_VARS [id] is telling the document to get the variable "id" you can change "id" to what ever you want. But what ever you change it to must be changed after index.php? So for instanced what we have above, would make the address look like this http://blahblah.com/index.php?id

Code:
//Default - case
default:
include "main.php";
break;


Now you are defining the default document that is to be loaded if no ?id is specified. So type in include" "; your default doc such as a news page. Make sure you have break; on its own line, and make sure that it is in there after each case.




Code:
//Fonts - case
case 'fonts':
include 'fonts.php';
break;


Next what we have is a case it is basically the same thing as the default case but you are defining what to do if the web address is blahblha.com/index.php?id=fonts . What it is saying is if "Fonts" is existant after ?id= then include 'fonts.php'; so what you want to do is replace fonts.php and change the case to what ever you want.

}
?>


Step 3
Put the entire php code where you want each page to load, keep in mind that each page will load at the same place no matter what, and backgrounds are not included either.

Step 4
The final step is to link text or buttons or what ever to each switch.. You do this by adding an <a href="index.php?id=fonts">Some Text</a> to your site or navigation.
Now when ever someone clicks that link "Some Text" it will goto the case "fonts" look to see what action it is told to do.. since it is include the page fonts.php it will include fonts.php where ever you place the php code at.

Continue to link each ahref to each case changing the id name (?id=fonts) make sure you do not specify a target or it will popup in a new window.

Note: Make sure to save the page that has the php code in it as a .php or .php3 file, if you don't it will not work and your navigation code will go kabloome.
b4r4t
It's nice tutorial Smile
Here is an example:

http://poker.ovh.org/switch/

and the ziped page:

http://poker.ovh.org/switch/switch.rar

it's little improved - look on Title Bars Smile Someone may use it to have diffrent titles/keywords for each subpage Smile
krazycapital
Nice tutorial dude. Good writing skills.
NOT
http://www.zymic.com/view_tutorial.php?id=96
Hobbit
OWNED TO T3H EXTREME!!!111oneone(serioulsy).

Wow, I've lost all my respect to you. Just wondering, DO YOU KNOW HTML?
DanielXP
he has not even change the works Confused

and i think its a new person
Related topics
Script php about gallery
PHP Toturail
Site Nav Suggestions...
Google Pack (Bundels NAV 05 for 6 months)
php, css question (wordpress)
RPG Maker... for all of you who want to make your own game!
Lemmings
PHP using Sessions
Php nav links?
PHP has stopped displaying my nav
include() Problem
Active Button With Css And Php...
Those crappy made for TV products
Adding a Nav Bar to my PHP forum
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.