Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-09-2003, 03:57 AM   PM User | #1
WeBFreaKZ
New Coder

 
Join Date: Mar 2003
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
WeBFreaKZ is an unknown quantity at this point
Creating a index.php?view=thing

there my subject actualy says it...

Is there a way that i can make it like index.php?view=contact
or something like that???
WeBFreaKZ is offline   Reply With Quote
Old 10-09-2003, 06:21 AM   PM User | #2
Cloudski
Regular Coder

 
Join Date: Jul 2002
Location: U.S. (Wish Japan though)
Posts: 141
Thanks: 0
Thanked 0 Times in 0 Posts
Cloudski is an unknown quantity at this point
Just make a link to the page:
Code:
<a href="page.php?action=view">Link</a>
Or something like that... Unless I am misunderstanding your question?
Cloudski is offline   Reply With Quote
Old 10-09-2003, 12:30 PM   PM User | #3
SDP2006
Regular Coder

 
Join Date: May 2003
Location: 34° 54' N 82° 13' W
Posts: 996
Thanks: 0
Thanked 0 Times in 0 Posts
SDP2006 is an unknown quantity at this point
Yes, you are majorly misunderstanding his question.

Okay
?action=view is called a query.

There are a lot of ways to do this, I'm gonna show you one that you might consider using, but If you have a lot of links, I would not recommend this.
PHP Code:
<?php
$page 
$_GET['action'];
switch (
$page
{
    case 
"home":
        
$include "includes/index.html";
    break;

    case 
"arts":
    
$include "includes/arts.html";
    break;

    case 
"aaexpert":
    
$include "includes/aaexpert.html";
    break;

    case 
"career":
    
$include "includes/career.html";
    break;

    case 
"comics":
    
$include "includes/comics.html";
    break;

    case 
"graphics":
    
$include "includes/graphics.html";
    break;

    case 
"computers":
    
$include "includes/computers.html";
    break;

    case 
"consumers":
    
$include "includes/consumer.html";
    break;

    default:
                
$include "includes/home.html";
    break;
}
include (
$include);
?>
Now when you link, name this page something like links.php or cats.php or whatever.php! For instance http://www.yourdomain.com/whatever.php?action=computers

That would include computers.html. You'll obviously need to change the paths/to/files.

Hope this helps.
__________________
Stevie Peele
Neverside IRC Network - irc.veonex.net | tc.tutorialnetwork.org
#dev - any programming,etc. question
#design - design discussion and critque
#central - general chat
Come join us!

Last edited by SDP2006; 10-09-2003 at 12:34 PM..
SDP2006 is offline   Reply With Quote
Old 10-09-2003, 05:06 PM   PM User | #4
missing-score
Senior Coder


 
missing-score's Avatar
 
Join Date: Jan 2003
Location: UK
Posts: 2,194
Thanks: 0
Thanked 0 Times in 0 Posts
missing-score is on a distinguished road
another simple way would be to have an array of pages, but once again, not reccomended for very big sites.

PHP Code:

<?php

$pages 
= array(
'page1'=>'page1.html',
'page2'=>'page2.html',
'home'=>'index.html');

if(isset(
$_GET['view']) && isset($pages[$_GET['view']])){

       include(
$pages[$_GET['view']]);

} else {

      include(
'defaultpage.html');

}

?>
missing-score is offline   Reply With Quote
Old 10-09-2003, 06:17 PM   PM User | #5
SDP2006
Regular Coder

 
Join Date: May 2003
Location: 34° 54' N 82° 13' W
Posts: 996
Thanks: 0
Thanked 0 Times in 0 Posts
SDP2006 is an unknown quantity at this point
Yeah, I would recommend the array. Its much easier and the case: break; can get kinda old and long.

Well, I learned something new today, thanks missing-score
__________________
Stevie Peele
Neverside IRC Network - irc.veonex.net | tc.tutorialnetwork.org
#dev - any programming,etc. question
#design - design discussion and critque
#central - general chat
Come join us!
SDP2006 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:16 PM.


Advertisement
Log in to turn off these ads.