Liam Armour
Liam Armour

Reputation: 119

PHP If statement page split up

I'm currently using if statements to split up one document into multiple pages, this may be the wrong way to do it but it works.

For example each page is something like ?Page=PAGENAME

When i first load the page the href has to be stats.php?Page=Main

Is there a way to have the code default to page main? rather than it been hard coded into the ?

Upvotes: 0

Views: 61

Answers (1)

Thanasis Pap
Thanasis Pap

Reputation: 2051

This is really not the way to do it but in order to answer your question, you can put on top of your php the following:

$page = empty($_GET['Page']) ? 'Main' : $_GET['Page'];

This will result in $page having always a value, if the parameter is set then it will have this one, if not it will take the string 'Main'.

Upvotes: 2

Related Questions