nemxu Posted January 28, 2007 Share Posted January 28, 2007 Hey there,Right I am going to try and explain this the best way I can. Hopefully you will understand what I am trying to say :DWhen I was very much into websites I had a PHP code which enabled me NOT to change every single page when I add a new link to the main page. For example I had the index.html with all the links and the main content... Now where the main content is there used to be a PHP code, which links to the other pages. So for example... when I wanted to upload contacts.php all I would have to do is write what I want for that page with the PHP code at the top and it used to link it with the main page, but just change the main content.It sounds complicated or maybe I don't Know how to explain myself, however all help would greatly be appreciated... Thanks Link to comment https://forums.phpfreaks.com/topic/36099-php-code/ Share on other sites More sharing options...
Orio Posted January 28, 2007 Share Posted January 28, 2007 So... What's the question?Orio. Link to comment https://forums.phpfreaks.com/topic/36099-php-code/#findComment-171351 Share on other sites More sharing options...
nemxu Posted January 28, 2007 Author Share Posted January 28, 2007 BY any chance do you know the code? Link to comment https://forums.phpfreaks.com/topic/36099-php-code/#findComment-171359 Share on other sites More sharing options...
Hypnos Posted January 28, 2007 Share Posted January 28, 2007 index.php:[code]<html><body>This is my site!I have links here.<a href="index.php?page=contacts">Contacts</a><?phpif($_GET['page'] == "contacts") include("contacts.php");else include("news.php");?>That's my content, thanks for visiting.</body></html>[/code]That style that you're talking about, and that I showed, requires the famous "page=" type of navigation. My personal opinion is that this style navigation is complete garbage, but it is not my site.I prefer making header and footer files, and then including them on each php page. Link to comment https://forums.phpfreaks.com/topic/36099-php-code/#findComment-171376 Share on other sites More sharing options...
nemxu Posted January 28, 2007 Author Share Posted January 28, 2007 [quote]<?phpif($_GET['page'] == "contacts") include("contacts.php");else include("news.php");?>[/quote]Do I need to add all the pages to this link? for example, "about us"? Link to comment https://forums.phpfreaks.com/topic/36099-php-code/#findComment-171381 Share on other sites More sharing options...
Hypnos Posted January 28, 2007 Share Posted January 28, 2007 You can just keep doing elseifs, but that would be ugly. Something like this would be cleaner:[code=php:0]switch ($_GET['page']) { case "contacts": include("contacts.php"); break; case "aboutus": include("aboutus.php"); break; default: include ("news.php");}[/code] Link to comment https://forums.phpfreaks.com/topic/36099-php-code/#findComment-171399 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.