Problem with "dynamic" index page


Posted on 16th Feb 2014 07:03 pm by admin

Hi. I have one question. In my index.php page I have this kind of code:
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?

No comments posted yet

Your Answer:

Login to answer
195 Like 47 Dislike
Previous forums Next forums
Other forums

disable all input buttons
Hello Friends,

suppose i do have a file ( file.php ) has a submit button

Code: [Sele

Feed Maker
Hi all.
First of all I must say I am not a php developer so I am afraid I don't know much about i

Php script to read msword file
hi,

I need to read a msword file and i want to print the contents in that word file.

i

scandir clients directory
hi,
how can i scandir the clients directory? i need a script that when i click a button it will u

List/Menu Box
On an edit page when you want something to select what a user has previously selected from the datab

unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_
Can anyone view my code and tell me why im getting the error:
Parse error: syntax error, unexpect

Count Session and Trigger Events
I am New in PHP, seeking a method to count logged users by counting the sessions or any …, is

Detail Expenses Report by Cost Center
I would like to obtain a report out of SAP that shows a list of expenses by cost center that shows t

use an array from 1 class in a second class
I have a class that adds data to an array

Then I have a second class and I need to check if t

TinyMCE / Ajax Postback Problem
Hiya all,

I have a page which loads the TinyMCE editor. On the postback I obviously want to f

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash