1

I have a few cases for pages which are being loaded using Ajax. Each case loads perfectly apart from the default at the bottom. It just doesn't display anything.

switch($_GET['page'])  {  

    case '#filemanager' : $page = '
        <div class="innerbox">
            <p>Demo text for the file manager page</p>
        </div>'; break;

    case '#todo' : $page = '
        <div class="innerbox">
            <p>Demo text for the to-do page</p>
        </div>'; break;

    default: $page = '
        <div class="innerbox">
            <h1>ADMIN CONTROL PANEL</h1>
        </div>'; break;

}
echo $page;

Is there something wrong I have done in the code? If so a quick helping hand would be much appreciated.

Regards

2
  • nothing looks wrong, try <p>ADMIN CONTROL PANEL</p> Commented Jul 17, 2012 at 14:12
  • @VinayWadhwa: tried and didn't make a difference Commented Jul 17, 2012 at 14:39

1 Answer 1

3

The code should work, see this example.

Most likely the problem is that $_GET['page'] is not set and you run into a php warning. You can avoid that by using:

$get = isset($_GET['page']) ? $_GET['page'] : 'default or something';
switch($get) {
    ...
Sign up to request clarification or add additional context in comments.

3 Comments

Hi, thanks for your reply but this didn't make a difference. I also forgot to say that for each case, it adds the case ID on to the end of the url for example, admin/php#todo. Does this make a difference?
@Lodder But in that case the variable would not be present in $_GET or are you encoding the value of #?
got it working now, thanks for pointing me in the right direction.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.