Forum Moderators: coopster

Message Too Old, No Replies

help with strings

how do I make the url: index.php?pageid=1

         

electricocean

5:33 am on Mar 25, 2005 (gmt 0)

10+ Year Member



How would I make a page that excutes the strings and changes an include file when someone clicks a link that is linked to 'index.php?pageid=1'?

thanks,

electricocean

dreamcatcher

9:19 am on Mar 25, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi,


$pageid = $_GET['pageid']

if (!empty($pageid))
{
switch ($pageid)
{
case 1:
@include('pageone.php');
break;

case 2:
@include('pagetwo.php');
break
}
}

Hope that helps.

dc

charlier

9:41 am on Mar 25, 2005 (gmt 0)

10+ Year Member



You could also use the pageID directly as a part of the include file name. Useful if there are > 4 or 5.

$Path = "/where/the/files/are";
$PageID = $_GET["pageid"];

//catch urls without a pageid.
if(! $PageID)
include("$Path/Default_Page.html");

//brackets needed as . can be used in variable names.
$filename = "$Path/Page_${PageID}.html";

//check for missing pages
if (! file_exists($filename))
include("$Path/Missing_Page.html");

//everything ok so get the page.
include($filename);

electricocean

11:50 pm on Mar 25, 2005 (gmt 0)

10+ Year Member



Thank you,

the first code is easy to understand and I am going to to try it...

$pageid = $_GET['pageid']

if (!empty($pageid))
{
switch ($pageid)
{
case 1:
@include('pageone.php');
break;

case 2:
@include('pagetwo.php');
break
}
}

so.... if I did that how would I set the main include() that loads when the page is first opened?

electrocean

electricocean

6:52 am on Mar 26, 2005 (gmt 0)

10+ Year Member



When ever I load the page it always says parse error. The line was was line that said ' if (!empty($pageid)) '. Is there something wrong?

electricocean

Salsa

7:34 am on Mar 26, 2005 (gmt 0)

10+ Year Member



Yes, something is wrong. Does that answer your question?

What kind of parse error was it? It always helps to give that kind of information when you want help. Errors are not always reported on exactly the line where they occur. If it says:

Parse error: parse error, unexpected T_IF in...

...it's probably that the line above is missing its ending semicolin.

I hope this helps.

dreamcatcher

8:02 am on Mar 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi,

Yes, sorry the last break in my example is missing a semi colon a la Salsa`s suggestion.

dc

electricocean

11:35 pm on Mar 27, 2005 (gmt 0)

10+ Year Member



yay! thanks it works....

electricocean