Jump to content

[SOLVED] Using switch to show different pages doesn't work


Gazan

Recommended Posts

Hey experts, i'm having this issue with switch..

 

It's just that, i use it to show different pages. Etc. www.url.com?show=gallerypage, www.url.com?show=contactpage. I want to show some content by default, if none of the above options are chosen. My code are as follow:

 

$page = $_GET['page'];

switch ($page) {

case 'contactpage':
echo "This is the contact page.";
break;

case 'gallerypage':
echo "This is the gallery page':
break;

default:
echo "This is the frontpage.";
break;

}

 

with this i want to make it like, if there has not been chosen a $page then it shows the default "This is the frontpage." But how do i make it work like that?

Yeah, thats what i'd like. Like, the links in the menu will be as i've typed with www.url.com/index.php?show=example. But when i go onto the page (www.url.com/index.php) it shall show some content as default, and then when you click some of the menu links, it will go to one of the switch options with the matching value.

 

EDIT:

 

I get the following error "no index defined" with the script..

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.