Re: switch() for links like ?id=index problem
| From: | Matt McClanahan | Date: | Fri, 16 Nov 2001 23:02:21 +0000 |
| Subject: | Re: switch() for links like ?id=index problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-74943@lists.php.net to get a copy of this message | ||
On Fri, Nov 16, 2001 at 06:22:19AM -0600, Ann Jamison wrote:
> my code looks something like this:
>
> switch($id) {
> case "home": include("home.php");
> break;
> }
> so links can be something like www.url.com?id=home
> I have also tried to use require instead of include
>
> When the desitred link is clicked, the page loads the new link, but also
> includes my index page taked onto the bottom of the new pages.
>
> what can I do to prevent this?
Well, don't put your index page outside the scope of the switch loop.
E.g,
switch ($id)
{
case "foo":
case "bar":
..
..
..
default:
include ('index_page.php');
}
Then your index page goes in index_page.php, and the actual index
becomes a simple dispatching page with no content in it.
Matt