Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Mar 2003
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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???

  • #2
    Regular Coder
    Join Date
    Jul 2002
    Location
    U.S. (Wish Japan though)
    Posts
    141
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?

  • #3
    Regular Coder
    Join Date
    May 2003
    Location
    34° 54' N 82° 13' W
    Posts
    996
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    Last edited by SDP2006; 10-09-2003 at 12:34 PM.
    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!

  • #4
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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');

    }

    ?>

  • #5
    Regular Coder
    Join Date
    May 2003
    Location
    34° 54' N 82° 13' W
    Posts
    996
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •