Forgot Password / Register
Site Statistics
Total Members: 520
Total Tutorials: 242
Newsest User: 8884244477
Todays Unique Hits: 616
0 Users 3 Guests Online

PHP Switch

Befor u start using this tutorial you need to deside what GET variable your navigation will use. For example, this tutorial will use $_GET['page'], this means that our links will be displayed as href='?page=about'>About


PHP Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?php

switch($_GET['page']) {  //gets the case and you can edit 'page' to be what you like. example: ?page= or ?sitename=

case "about"// this is the case that the switch would display when clicked
include ('about.php'); //when the case is called it will display what page you have added. also u can add an echo instead of a include
break;  //stops the case i believe

case "hello"://this is the case that the switch would display when clicked
echo "Hello world!";// this is display whatever text you add again u can change is to a include
break; //stops the case i believe


default: // default would be whatever page u want to be displayed befor someone clicks a link i use news.php
include ('news.php'); // page thats displayed befor a link is clicked or if someone tryed to access a page that isnt there.
break; //stops the case i believe

}
Adam981
Author:
Views:
2292
Rating:
Posted on Saturday 7th June 2008 at 04:05 PM
darklight19
darklight19
I've been doing it this way for a while. :)
Posted on Friday 6th June 2008 at 06:56 PM
Adam981
Adam981
Thanks, not bad for my first tutorial :P
Posted on Friday 6th June 2008 at 11:48 AM
ilyas-shezad
ilyas-shezad
Nice very simple and easy to understand
Posted on Friday 6th June 2008 at 06:48 AM
SkillMaster
SkillMaster
I use this in a lot of my tutorials.
Posted on Friday 6th June 2008 at 03:43 AM
Adam981
Adam981
Thanks :) i figured i'd post a working one :P
Posted on Friday 6th June 2008 at 03:40 AM
Nathan
Nathan
this is a great tutorial and its easy to use.