Jump to content


Photo

breaking.


  • Please log in to reply
3 replies to this topic

#1 xyn

xyn
  • Members
  • PipPipPip
  • Advanced Member
  • 779 posts
  • LocationNorthampton

Posted 06 July 2006 - 09:59 AM

Hi,
I have my script which is attached below, I have it in the correct place on my Index.php page and I have the "exit;" code but this obviously exits the loading so I can't load the rest of the page to show my copyright and Links at the bottom.

I'm basically wondering if anyone has any directional help they could offer me to swapping the exit; with break; and then at the bottom of the code i can return; the script. although when i last tried it I got parse errors.

<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" height="184">
  <tr>
    <td width="100%" height="57" colspan="2">
    <p align="center">Top</td>
  </tr>
  <tr>
    <td width="21%" height="93">Nav</td>
    <td width="79%" height="93"><?PHP
    $p = $_GET['page'];
    
    if( !$p ){
    include "welcome.php";
    break;
    
    } elseif( $p == action ){
    include "page.php";
    break;
    
    }else{
    die('No such page');
    }
    	return;
    ?></td>
  </tr>
  <tr>
    <td width="100%" height="32" colspan="2">
    <p align="center">copyright</td>
  </tr>
</table>


#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 06 July 2006 - 10:08 AM

Try a switch statment instead:
switch(@$_GET['page'])
{
    case 'action':
        include "page.php";
    break;

    default:
        if(!isset($_GET['page']))
        {
            echo 'No such page';
        }
        else
        {
            include "welcome.php";
        }
    break;
}


#3 xyn

xyn
  • Members
  • PipPipPip
  • Advanced Member
  • 779 posts
  • LocationNorthampton

Posted 06 July 2006 - 10:09 AM

alright how do i add other pages into the switch?

#4 heckenschutze

heckenschutze
  • Members
  • PipPipPip
  • Advanced Member
  • 257 posts
  • LocationAustralia

Posted 06 July 2006 - 10:20 AM

Add more cases!

switch(@$_GET['page'])
{
    case 'action':
        include "page.php";
    break;

    case 'mysecondaction':
        include "mysecondpage.php";
    break;

    default:
        if(!isset($_GET['page']))
        {
            echo 'No such page';
        }
        else
        {
            include "welcome.php";
        }
    break;
}





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users