Originally posted by viper21634
yeah, I had thought of that, but I want to try to see if I can get the query string to work. the reason?? I the page with the switch, has about 200 lines of included files all with query strings. So, you see my delima.
Yes, it sounds like you'd be wanting to store the filenames (and their parameters) in an array which you can index by case; get PHP to work through all the individual cases.
Build by hook or by crook (suck it out of a database or (probably cleaner for static nav) PHP code in an included config file) an array summat like:
$pages=array(
'info'=>array('sect'='info', 'file'='page.php'),
'users'=>array('sect'='list', 'file'='users.php'),
...
);
And then replace the whole switch($page){...} block with
$sect=$pages[$page]['sect'];
include($pages[$page]['file']);
Kind of a programming principle that: if you find yourself doing something tedious and repetitive, ask yourself why you don't just get a machine to do it for you. Laziness is a virtue 🙂
[Edit:]Just noticed something: viper21634, after coding a switch that "has about 200 lines of included files all with query strings" then finds out that the approach is broken...