Jump to content

Recommended Posts

Hi. I have one question. In my index.php page I have this kind of code:

// listaa sivut
$pages = Array (
"etusivu" => "etusivu.php",,
"linkit" => "linkit.php",
"yhteydet" => "yhteydet.php",
"tiedotteet" => "tiedote.php",
"uutiset" => "uutiset.php",
"tapahtumat" => "tapahtumat.php",
);
// Jos sivua ei loydy, naytetaan etusivu
$page = ($_GET["page"] != "") ? $_GET["page"] : "etusivu";
if (isset($pages[$page]) AND file_exists($pages[$page])) {
include ($pages[$page]);
} else {
// Jotakin vaarin! naytetaan 404-viesti
echo "Virhe 404 - Sivua ei löydy!";
}
function MakeArray ($dir) {
global $pages;
$handle = OpenDir ($dir) or die ("Couldn't open $handle!");
while (FALSE !== ($file = ReadDir($handle))) {
if ($file != ".." AND $file != ".") {
if (is_dir($dir . $file)) {
MakeArray ($dir . $file . "/");
} else {
$pages[ereg_replace("\.(.*)$", "", $file)] = $dir . $file;
}
}
}

CloseDir ($handle);
}
?>

Ewerything else works ok, but I want put in $pages array page  tapahtumat&page=2. How to do it?

 

I mean that this addres works in index php:

www.mydomain.com/index.php?page=tapahtumat

 

This addres does not work:

www.mydomain.com/index.php?page=tapahtumat&page=2

 

What I have to do?

 

Link to comment
https://forums.phpfreaks.com/topic/182608-problem-with-dynamic-index-page/
Share on other sites

Not that this is going to be super helpful, but its worth mentioning.

 

The URL: index.php?page=tapahtumat&page=2

Can't contain the same variable twice. The same variable will just either null the other out or one will override the other.

 

Try altering it to work with a url more like: index.php?page=tapahtumat&pg=2

 

sorry I am tired or I would be of more help, I am currently waiting on some help in another topic myself.

Not that this is going to be super helpful, but its worth mentioning.

 

The URL: index.php?page=tapahtumat&page=2

Can't contain the same variable twice. The same variable will just either null the other out or one will override the other.

 

Try altering it to work with a url more like: index.php?page=tapahtumat&pg=2

 

sorry I am tired or I would be of more help, I am currently waiting on some help in another topic myself.

 

Thank you! This helped a lot. Now ewerything is working great!!

 

Thanks again!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.