droopy Posted April 15, 2006 Share Posted April 15, 2006 Hi all,I am new at this forum and first off all sorry for my bad english, i am dutch.My name is Anthony and learning php which goes well (besides now).My question might be simple to some of the guru's here but i cant find the answer to it.How can i create a navigation that calls the index + the page. Like index.php?page=startCan someone tell me?Thank you.Anthony(droopy) Quote Link to comment https://forums.phpfreaks.com/topic/7469-php-navigation/ Share on other sites More sharing options...
redarrow Posted April 15, 2006 Share Posted April 15, 2006 [!--quoteo(post=365031:date=Apr 15 2006, 10:03 AM:name=droopy)--][div class=\'quotetop\']QUOTE(droopy @ Apr 15 2006, 10:03 AM) [snapback]365031[/snapback][/div][div class=\'quotemain\'][!--quotec--]Hi all,I am new at this forum and first off all sorry for my bad english, i am dutch.My name is Anthony and learning php which goes well (besides now).My question might be simple to some of the guru's here but i cant find the answer to it.How can i create a navigation that calls the index + the page. Like index.php?page=startCan someone tell me?Thank you.Anthony(droopy)[/quote]lookup GET[!--quoteo(post=365033:date=Apr 15 2006, 10:07 AM:name=redarrow)--][div class=\'quotetop\']QUOTE(redarrow @ Apr 15 2006, 10:07 AM) [snapback]365033[/snapback][/div][div class=\'quotemain\'][!--quotec--]lookup GET[/quote][code]<?php$prefix = '/path/to/file/myPrefix.';$postfix = '.inc.php';$defaultPage = 'home';$errorPage = '404';$incFile = $prefix . $_GET['page'] . $postfix;$default = $prefix . $defaultPage . $postfix;$error = $prefix . $errorPage . $postfix;if(file_exists($incFile)){switch($_GET['page']){case 'home':case 'about':case 'contact':include_once $incFile;break;case '':@include_once $default;break;default:@include_once $error;break;}}else{echo '<h1>Page Not Found: 404</h1>';}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/7469-php-navigation/#findComment-27206 Share on other sites More sharing options...
redarrow Posted April 15, 2006 Share Posted April 15, 2006 [!--quoteo(post=365033:date=Apr 15 2006, 10:13 AM:name=redarrow)--][div class=\'quotetop\']QUOTE(redarrow @ Apr 15 2006, 10:13 AM) [snapback]365033[/snapback][/div][div class=\'quotemain\'][!--quotec--]lookup GET[code]<?php$prefix = '/path/to/file/myPrefix.';$postfix = '.inc.php';$defaultPage = 'home';$errorPage = '404';$incFile = $prefix . $_GET['page'] . $postfix;$default = $prefix . $defaultPage . $postfix;$error = $prefix . $errorPage . $postfix;if(file_exists($incFile)){switch($_GET['page']){case 'home':case 'about':case 'contact':include_once $incFile;break;case '':@include_once $default;break;default:@include_once $error;break;}}else{echo '<h1>Page Not Found: 404</h1>';}?>[/code][/quote][code]When the menu contains a link like:main.php?main=navigationThe code in main.php might look like this:<?$dir = "pages/";if (isset($_GET['main'])) {$filename = $dir.$_GET['main'].'php';if (file_exists($filename)) {include $filename;exit;}}include "{$dir}default.php";?>[/code][a href=\"http://www.webmonkey.com//99/25/index2a.html\" target=\"_blank\"]http://www.webmonkey.com//99/25/index2a.html[/a]this will teach you it all good luck Quote Link to comment https://forums.phpfreaks.com/topic/7469-php-navigation/#findComment-27208 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.