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
47
Other forums
Is there a function ... auto send IP
Is there some function that can be sent to a ddns service that returns the ip address of a ddns forw
Echoing If Function?
A script I am using has If statements in the comments form to basically tell the form what to do. Cu
How to get the previous months last date....
Here's my wittle problem. I suck at working with dates.
So today is 10/20/2009, i need to fig
UDP server recvfrom() always returns -1? :(
Hello all,
I am getting a very strange error in my code :( I am writing a server application in C
Most basic form question ever?
Hello,
I want to use this snippet to make sure the fields in a form are ok before processing
upload control not working with update panel
Hi,
I am working with Asp.Net FileUpload control with ajax update panel,
if i use the
private constructor
Hello,
Can we create a constructor as private? If yes, what is the use of it? If no, why can'
Custom CMS
This is a big custom CMS script I'd like to develop and would like some help atleast figuring out wh
chat
hello i'm amir
i need a chat source code in asp.net 2.0 without Ajax.
anybody can help me?
making web pages for accounts
Hello, I would like to make pages for accounts on my website im making (its not a real website..im j