Hi all!
I have this script to help me manage a page where a user choose a link, and them depending on their choice, they open a page within a template.
The problem is the last elseif statement:
elseif ($page=="all") {
$filename = "all.php";
}
I need this statement to include all the files mentioned previously:
ac.html. df.html.
I've tried arrays and functions.
On the page all.php I declared this function:
<?php
function CombineList ()
{
include ("ac.html");
include ("df.html");
include ("gi.html");
include ("jm.html");
include ("np.html");
include ("qt.html");
include ("uz.html");
}
?>
This works fine if I call the page directly, but if i pass it from below, I simply get a page with my php script on it.
Do I need to define $page in the function?
I am pulling hair out as I try to learn!
Here is the full script:
<?php
$page = $_GET["page"];
if ($page=="ac") {
$filename = "ac.html";
}
elseif ($page=="df") {
$filename = "df.html";
}
elseif ($page=="gi") {
$filename = "gi.html";
}
elseif ($page=="jm") {
$filename = "jm.html";
}
elseif ($page=="np") {
$filename = "np.html";
}
elseif ($page=="qt") {
$filename = "qt.html";
}
elseif ($page=="uz") {
$filename = "uz.html";
}
elseif ($page=="all") {
$filename = "all.php";
}
$F = fopen($filename,"r");
while (!feof ($F)) {
$buffer = fgets($F, 4096);
echo nl2br($buffer);
}
fclose ($F);
?>