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:

<html>
<body>

<? 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)
<? } ?>

</body>
</html>

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! :)

You don't need a switch statement

<?php
$day = intval($_GET['day']);
if($day >0 && $day <8) {
  include('day' . $day . '.php');
} else {
  echo  'Invalid page';
}
?>
commented: Much better. +19
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.