I'd say there's an easier way than switches...
<?
if(!empty($_GET['page_id'] && is_int($_GET['page_id']))
{
$page_id = $_GET['page_id'];
}
else
{
// default if no id was passed, or it wasn't an integer
$page_id = "1";
}
$file = "inc/page_" . $page_id . ".inc"; // eg page_18.inc
if(file_exists($file))
{
include($file);
}
else
{
include('inc/page_missing.inc');
}
?>
The difference being that there's no extra code (case statements) for 1000
different page_id's, or just 5 page_id's, and I've included pretty much all
the fallbacks for missing page_id, missing include files, etc etc.
You just need a /inc/ dir full of page_n.inc files.
Good luck!
Justin French
on 12/07/02 12:43 AM, Martin Clifford ([EMAIL PROTECTED]) wrote:
> The easiest way to accomplish that is by using switches. Here is an example:
>
> switch($pageid) {
> default:
> include("default_page.inc");
> break;
> case "18":
> include("page_18.inc");
> break;
> }
>
> With that in your index.php page, it will look for the variable $pageid, and
> depending on what it is set to, display the appropriate information. In this
> instance, it will display the default index page by default (if $pageid is
> empty), or page_18.inc if $pageid = 18.
>
> Hope that helps :o)
>
>>>> "Craig" <[EMAIL PROTECTED]> 07/11/02 10:42AM >>>
> I want to acheive something like this
>
> http://www.claviga.com/index.php?pageid=18
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php