| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| Senior Member Join Date: Aug 2005 Location: England
Posts: 1,196
![]() ![]() ![]() ![]() ![]() ![]() | using includes? I have a website that I have sliced and out to html, then renamed to php (lazy way i know) in the centre i use php include to take the news from the forums and display it in centre of home page...how do i make the buttons do the same, i.e if i click templates a new page opens where the news once was and so on...please don't say iframes my only options... |
| |
| | #2 (permalink) |
| The original NP Emo Kid Join Date: Jan 2005 Location: Plymouth, UK
Posts: 1,693
![]() ![]() ![]() ![]() ![]() ![]() | You could do something like this (pretty much what i use, although a little less complicated); For navigation links: index.php?page=somepage Then for the actual including code do something like this PHP Code: ????: NamePros.com http://www.namepros.com/programming/170064-using-includes.html Hope it helps.
__________________ Gaming On Linux - Because Linux is Fun! |
| |
| | THREAD STARTER #3 (permalink) | ||||
| Senior Member Join Date: Aug 2005 Location: England
Posts: 1,196
![]() ![]() ![]() ![]() ![]() ![]() |
.p.s how much would you charge to do 1 link for me so i can see how it's done.... | ||||
| |
| | #4 (permalink) |
| The original NP Emo Kid Join Date: Jan 2005 Location: Plymouth, UK
Posts: 1,693
![]() ![]() ![]() ![]() ![]() ![]() | I can do it for free. Do this; PHP Code: Assign each link like this (these are examples); home = index.php?page=home news = index.php?page=news Hope that helps.
__________________ Gaming On Linux - Because Linux is Fun! |
| |
| | #5 (permalink) |
| NamePros Member Join Date: Feb 2006 Location: Chicago IL
Posts: 73
![]() | It's not as good, but you could also do just simple HTML pages for each of the pages, and just put a different include in each page for the content.. But Liam's way is MUCH better. I've been meaning to do this myself for all of my websites... But I'm far too busy. Rep Added Liam
__________________ Hassle Free Computing and Web Solutions for Personal and Business! Rochelle Network Communications! |
| |
| | #6 (permalink) |
| Tech Support Join Date: Mar 2005
Posts: 4,944
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Using switch(); is another option.. PHP Code: |
| |
| | #7 (permalink) |
| NamePros Member Join Date: Feb 2006 Location: Chicago IL
Posts: 73
![]() | Which is better? Switch or Liam's code?
__________________ Hassle Free Computing and Web Solutions for Personal and Business! Rochelle Network Communications! |
| |
| | #8 (permalink) |
| The original NP Emo Kid Join Date: Jan 2005 Location: Plymouth, UK
Posts: 1,693
![]() ![]() ![]() ![]() ![]() ![]() | They both work, but switches code makes a tedious task of adding in more pages as you have to add in a new case each time. With mine you don't need to add anything. And glad i could help
__________________ Gaming On Linux - Because Linux is Fun! |
| |
| | #9 (permalink) |
| NamePros Regular Join Date: Aug 2005 Location: NY, USA
Posts: 608
![]() ![]() ![]() ![]() ![]() ![]() | With liam's code, however, there is a possibility that someone could do something to the effect of 'http://www.yoursite.com?page=http://www.someonessite.com/theirscript' and execute code on your page. ????: NamePros.com http://www.namepros.com/showthread.php?t=170064 I would suggest either using switch() or using this code insteaed: Code: <?php
if(isset($_GET['page']))
if(file_exists("./pages/" .$_GET['page']. ".php"))
include("./pages/" .$_GET['page']. ".php");
else
include("./pages/404.php");
else
include("./pages/default.php");
?>
__________________ ask me about the internet |
| |
| | #10 (permalink) |
| The original NP Emo Kid Join Date: Jan 2005 Location: Plymouth, UK
Posts: 1,693
![]() ![]() ![]() ![]() ![]() ![]() | Yeah it is always a good idea to make sure you check the pages. Can also be done with an array, check if the page is an an array of files you set.
__________________ Gaming On Linux - Because Linux is Fun! |
| |
| | THREAD STARTER #11 (permalink) |
| Senior Member Join Date: Aug 2005 Location: England
Posts: 1,196
![]() ![]() ![]() ![]() ![]() ![]() | oh man, my head hurts, liam sent me a page with the code but it doesn't work....so i'll reg 2 domains at namecheap to anyone that can add the links to the index.php for me, whilst retianing the main loadpage as the news from the forums... |
| |
| | #12 (permalink) |
| The original NP Emo Kid Join Date: Jan 2005 Location: Plymouth, UK
Posts: 1,693
![]() ![]() ![]() ![]() ![]() ![]() | I have told you how to do it, i have done it for you and testing it and it works fine!
__________________ Gaming On Linux - Because Linux is Fun! |
| |
| | #13 (permalink) |
| Soon to be RICHdoggie! Join Date: Jan 2005 Location: UK
Posts: 2,408
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | reaper: Where you have the include already (the one you said you put in, in the very first post) just put in: PHP Code: |
| |
| | #15 (permalink) |
| The original NP Emo Kid Join Date: Jan 2005 Location: Plymouth, UK
Posts: 1,693
![]() ![]() ![]() ![]() ![]() ![]() | Thanks a lot, glad i could help
__________________ Gaming On Linux - Because Linux is Fun! |
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Includes | Albatross | Website Development | 5 | 06-14-2005 10:22 AM |
| 259 Domains for Sale (inc. goclassified.com) | fle8 | Domains For Sale - Make Offer | 0 | 05-02-2004 08:57 AM |
| HOWEIRDDEAN.COM includes website, plus 2 free doamins! | interneta | Domains For Sale - Make Offer | 6 | 02-17-2004 02:12 PM |