Page 1 of 1
how to make those easy links (like: blah.php?id=01)
Posted: Wed Nov 20, 2002 8:38 am
by snake
well the topic tells it all, how to make those easy links like blah.php?id=01
instaed of /fsdf/fdsf/fds/bleh.php
thanks
Posted: Wed Nov 20, 2002 9:19 am
by bumpy
well, if you just have a few pages with your website you could use a
switch:
You build your index.php for example like this:
Code: Select all
<?php
include("header.php");
//here your Menu with links like <a href="?id=1">page1</a>
switch ($_GETї"id"]) {
case 1: include("1.php"); break;
case 2: include("2.php"); break;
case 3: include("3.php"); break;
default: include("4.php");
}
include("footer.php");
?>
in 1.php, 2.php, ... you put your content; in the header.php and footer.php you put your html-layout
Wasn't that hard, huh?!

Posted: Wed Nov 20, 2002 1:49 pm
by snake
isn't there any other way to do this aswell if i want to link to a whole new page instead of using include...
i mean like if i want to link to eg php.net
i mean that ?id=php poits to php.net or similiar
Posted: Thu Nov 21, 2002 2:25 am
by twigletmac
If you wanted to then send people to another page entirely you would have to use
header() to redirect them. So it's almost the same as bumpy's example, however, you wouldn't want any output whatsoever before the header() function call (
viewtopic.php?t=1157)
Code: Select all
<?php
$id = (!empty($_GETї'id']) ? $_GETї'id'] : '';
switch ($id) {
case 'php':
header('Location: http://www.php.net/');
break;
case 'mysql':
header('Location: http://www.mysql.com/');
break;
default:
header('Location: http://www.mysite.com/');
}
?>
Mac