I have a PHP page with query strings in, and that works, but getting it to display the correct page depending on the day via a switch statement is a problem.

This is the code:


<? if($_GET['day']==1){ ?>
 <?php include("day1.php") ?>
<? }else if($_GET['day']==2){ ?>
 <?php include("day2.php") ?>
<? }else if($_GET['day']==3){ ?>
 <?php include("day3.php") ?>
 <? }else if($_GET['day']==4){ ?>
 <?php include("day4.php") ?>
 <? }else if($_GET['day']==5){ ?>
 <?php include("day5.php") ?>
 <? }else if($_GET['day']==6){ ?>
 <?php include("day6.php") ?>
 <? }else if($_GET['day']==5){ ?>
 <?php include("day7.php") ?>
<? }else if(!is_numeric($_GET['id']) || $_GET['id']<1){ ?>
invalid id (or page not found)
<? } ?>


I'm not sure about the switch statement to put after <? }else if(!is_numeric($_GET) || $_GET<1){ ?> so that it shows the correct page for myschedule.php page.

The actual site isn't online yet, so I haven't got any errors to show.

All advice is appreciated! Thanks for taking the time to help me when I posted my last problem! :)

9 Years
Discussion Span
Last Post by ShawnCplus

You don't need a switch statement

$day = intval($_GET['day']);
if($day >0 && $day <8) {
  include('day' . $day . '.php');
} else {
  echo  'Invalid page';
Votes + Comments
Much better.
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.