Page 2 of 3
Posted: Sun Nov 24, 2002 12:19 am
by hob_goblin
i foobared
Code: Select all
<?php
if($_GETї'page'] == "downloads"){
if(!isset($_GETї'download_id'])){
include 'downloads.php';
} else if($_GETї'download_id'] == "1"){
include 'games/1.php';
}
} else {
include('main.php');
}
?>
try that
Posted: Sun Nov 24, 2002 10:39 am
by Pocketx
IT WORKS!! THANKS MAN!
BTW, how do I add more pages like staff, reviews ect.?
Posted: Sun Nov 24, 2002 12:57 pm
by Pocketx
please help!
Posted: Sun Nov 24, 2002 9:34 pm
by Pocketx
Plz! Everything i try dosent work!
Posted: Mon Nov 25, 2002 3:32 am
by twigletmac
What have you tried - how does the code currently look? It's easier for us to help you edit your own code instead of writing code that may cause more problems when you try and integrate it.
Mac
Posted: Mon Nov 25, 2002 11:14 am
by Pocketx
Ive tryed to add an about page
Code: Select all
<?php
if($_GETї'page'] == "downloads"){
if(!isset($_GETї'download_id'])){
include 'downloads.php';
} else if($_GETї'download_id'] == "1"){
include 'games/1.php';
}
if($_GETї'page'] == "about"){
include 'about.php';
}
} else {
include('main.php');
}
?>
But dosent work
Posted: Mon Nov 25, 2002 5:42 pm
by Pocketx
HELP!! PLEASE THIS IS THE LAST TIME! JUST HELP ME AND ILl GET THE HECK OUT OF THIS PLACE... PLEASE HELP!
Posted: Mon Nov 25, 2002 11:24 pm
by BigE
Try this code.
Code: Select all
<?php
if($_GETї'page'] == "downloads"){
if(!isset($_GETї'download_id'])){
include 'downloads.php';
} else if($_GETї'download_id'] == "1"){
include 'games/1.php';
}
elseif($_GETї'page'] == "about"){
include 'about.php';
}
} else {
include('main.php');
}
?>
Also, you don't need to post multiple times. We will help when and if we can.
Posted: Thu Nov 28, 2002 9:33 pm
by Pocketx
Thanks but it dosent work.. I get the same information as the index.php instead of the about.php page
BTW Sorry to post double times, Im desperate
Posted: Fri Nov 29, 2002 2:00 am
by twigletmac
It's probably because the elseif for the about page is within the if statement for checking if it's the download page - $_GET['page'] cannot equal both 'downloads' and 'about' so you'll always include main.php for when $_GET['page'] is equal to about (looking at indented code makes it much easier to spot this kind of thing).
So what you probably need to do is move that elseif statement so your code looks something like:
Code: Select all
<?php
if ($_GETї'page'] == 'downloads'){
if (empty($_GETї'download_id'])){
include 'downloads.php';
} elseif ($_GETї'download_id'] == 1){
include 'games/1.php';
}
} elseif ($_GETї'page'] == 'about') {
include 'about.php';
} else {
include 'main.php';
}
?>
Mac
Posted: Fri Nov 29, 2002 2:34 pm
by Pocketx
wow.. thanks.. it works!
Posted: Sat Nov 30, 2002 2:23 am
by MeOnTheW3
I think a SWITCH statement may be cleaner and easier to scale, in this case:
//- First just grab all the variables in a backward-compatible manner
Code: Select all
<?php
foreach($HTTP_GET_VARS AS $key => $val)
{
//- Variable variables
// The value of $key becomes the variable name by $$key
$$key = $val;
}
?>
//- Now all the query string variables are available by the name as passed.
// for example: ...php?page=about
// foreach is run
// NOW
// $page holds the value 'about'
The following code allows for easy scalability and readability.
Code: Select all
<?php
switch($page)
{
case 'downloads':
switch( isset($download_id) ? $download_id : 0 ) // allow for empty($download_id)
{
case 0:
include('./downloads.php');
break;
case 1:
include('./games/1.php');
break;
case 2:
include('./games/2.php');
break;
default:
include('./downloads.php'); // fail-safe;
break;
}
break;
case 'about'
include('./about.php');
break;
case 'news'
include('./news.php');
break;
default:
break;
}
?>
Posted: Sat Nov 30, 2002 5:23 pm
by Pocketx
Then if you would to add the main page it would be
Code: Select all
<?php
switch($page)
{
case 'downloads':
switch( isset($download_id) ? $download_id : 0 ) // allow for empty($download_id)
{
case 0:
include('./downloads.php');
break;
case 1:
include('./games/1.php');
break;
case 2:
include('./games/2.php');
break;
default:
include('./downloads.php'); // fail-safe;
break;
}
break;
case 'about'
include('./about.php');
break;
case 'news'
include('./news.php');
break;
default:
include('./main.php');
break;
}
?>
Right?
Posted: Sat Nov 30, 2002 5:26 pm
by MeOnTheW3
Yes, if you wish main.php to load in all other cases.
Worked for you?
Posted: Sun Dec 01, 2002 5:37 pm
by Pocketx
The code dosent work
Parse error: parse error in /mnt/host-users/pocketx/test/index.php on line 24
which is include('./about.php');