Hey all,
Working on a script that will take a URL name, loop through an array, and spit out an include page assosiated with that URL name.
Such as....
//test data, this I want in MySQL
//This is the module name and the
//corosponding page to include
$mod = array (
array (
mod => "home",
location => "modules/def-news/index.php"),
array (
mod => "moblog",
location => "modules/def-moblog/index.php")
);
//Need some kind of checking of the
//above array to make sure people
//dont use random names and cause
//errors. Would like to display a
//generic error to users if a mod is
//not in the array.
//This section loops and makes a switch
//case setup. How to do default page
//with this loop??
foreach ($mod as $val) {
switch($_GET['module']) {
case "$val[mod]":
include "$val[location]";
break;
}
}
The comments speak for themselves.
Please and thank you...I know you guys can help me out 😃
PS. Forgot to mention, URLs look like this: http://mysite.com/?module=home
Basiclly if someone puts ?module=home44556 or something that is NOT in the array, I would like to display an error stating that the module does not exsist. I cant figure it out 🙁