Using Switch To Do This

Discussion in 'PHP' started by simonpeterong, Oct 8, 2007.

  1. #1
    How can I achieve a URL like this:

    mydomain.com/index.php?content=content1&item=content2&topic=content3

    Can I do this if I am using switch?

    If not, what is the best way to achieve this?:confused:

    Thanks.
     
    simonpeterong, Oct 8, 2007 IP
  2. Lordo

    Lordo Well-Known Member

    Messages:
    2,082
    Likes Received:
    58
    Best Answers:
    0
    Trophy Points:
    190
    #2
    You should give more details on content, item and topic. What are they? Is one of them an item ID to show?
     
    Lordo, Oct 8, 2007 IP
  3. matthewrobertbell

    matthewrobertbell Peon

    Messages:
    781
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Your question is very vague, do you mean how can you get the data from the url, or how to create the url?
     
    matthewrobertbell, Oct 8, 2007 IP
  4. tamen

    tamen Peon

    Messages:
    182
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    If you are talking about getting the values of content, content & content3, then is as easy as:
    $content = $_GET['content'];
    $content2 = $_GET['content2'];
    $content3 = $_GET['content3'];

    $content would then = 'content1'
    $content2 would then = 'content2'
    $content3 would then = 'content3'
     
    tamen, Oct 8, 2007 IP
  5. wvccboy

    wvccboy Notable Member

    Messages:
    2,632
    Likes Received:
    81
    Best Answers:
    1
    Trophy Points:
    250
    #5
    Yes you can use switch. Under the switch you have the first content1, then below you have content2. The way the URL is set up it's reading the switch like index.php?content, then under that it's building on top of the base part of the URL.
     
    wvccboy, Oct 8, 2007 IP