Multiple variable URL in a simple CMS

Hi guys, I have a simple problem I can’t get my head around.

I have a simple index.php which includes the relevant html pages to include for a given URL, e.g.:

<?php if($_GET['p']=='main'){ include("main.htm");} else{ include("main.htm"); } ?>

There’s a lot more choices and they work fine in there but I have only posted the above. Now my problem starts.

I have a simple CMS system for articles written on the site and I want a second variable to the URL, e.g.:

index.php?p=articles&id=1

So in index.php I would like something like this…

elseif($_GET[‘p’]==‘articles’){

include("./content/load_articles.php?[b]xxxxxx[/b]");}

But I’;m not sure what to put in xxxxxxxx

Hi there,

You don’t need to put anything after your include path. Just “./content/load_articles.php” is fine - including a page is the same as having that code in the same file, it literally just pulls that file’s code into the file calling the include() function. The php file you include will be able to use $_GET[‘id’] as long as the page that included it can (in this case it apparently can).

In summary - your new block of code should be:
[php]elseif($_GET[‘p’]==‘articles’)
{
include("./content/load_articles.php");
}[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service