Go Back   Pictual Design Forums > Webmaster > Programming
Top Posters Referers Register Members List Calendar Search Today's Posts Mark Forums Read

Programming Post any problems that you have coding or post any topics about coding here.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-30-2006, 05:48 AM
xplicit xplicit is offline
Deathgod - Shinigami
Lives Here
Elite Member (500+ posts)
 
Location: U.S.
Rep Power: 0
xplicit is an unknown quantity at this point
Default [PHP] Linking with includes

There is a post up on these boards about php linking, but its a bit outdated so I am here making a revised version. A useful code that allows for users to update sites without using mutiple pages of sites, instead drawing upon a single file for content.

Full code:
Code:
<?php switch($_GET['page']){ default: include_once('content/home.php'); break; case 'home': include 'content/home.php'; break; }?>

Now lets break this down for everyone.

Code:
<?php switch($_GET['page']){ default: include_once('content/home.php');
In simple this code basically tells the server to get the 'page' which can be changed to what ever you wish, but make sure when you do links, you change your links to what you changed it to. Also the default: include_once code tells what file to be shown by default just once, change the info in the (' ')'s correctly.

Example: "<?php switch($_GET['id']){" your links would be http://yourhost.com?id=case.

Code:
break;
As this line says, it breaks the current code and lets you start off on a different code. use this inbetween your different cases.

Code:
case 'home': include 'content/home.php'; break;
Starting with the first line, the case designated will determine to call upon info from a certain page. So your link would techinically be in this case http://yourhost.com?page=home .
the include 'url' code tells where to grab the file for the content.
When You want to create more links, simply add more to the case list.

Example:
Code:
<?php switch($_GET['page']){ default: include_once('content/home.php'); break; case 'home': include 'content/home.php'; break; case 'yourcase': include 'filelocation'; break; }?>

Hope that gives some of ya some things to use later on in websites. Let me know if anything is wrong or needs editing.
__________________
www.BrianLeee.com - Online Portfolio
Reply With Quote
  #2  
Old 08-30-2006, 05:02 PM
Peter's Avatar
Peter Peter is offline
Administrator
HeadLancer
Advanced Member (50+ posts)
 
Rep Power: 10
Peter is on a distinguished road
Default

Great tut! Moved to the Programming Forum
Reply With Quote
  #3  
Old 08-31-2006, 06:39 AM
Mifano's Avatar
Mifano Mifano is offline
Lives Here
Advanced Member (50+ posts)
 
Location: Stockholm, SWE
Rep Power: 4
Mifano is on a distinguished road
Send a message via MSN to Mifano
Default

Ohh nice, thank you!
__________________
Whenever i comment, suggest and post, im ME!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 05:06 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
vRewrite 1.5 beta SEOed URLs completed by Tech Help Forum and Chalo Na.