SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2009
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Switch case - how to pass variable

    I'm looking at trying out using switch case as a way to turn a division either on or off or with an include a file thing. The information I've seen so far is basic. That is, the discussion is on it's primary use.

    Using a standard link, how does one embed the variable into the link to pass the value on to the action?

    <a href="http://www.google.com">google</a>
    <a href="http://www.yahoo.com">yahoo</a>

    When google is clicked on, the google division shows. When yahoo is clicked the yahoo division is shown.

    Where and how does the value get placed?

  2. #2
    SitePoint Addict
    Join Date
    Jul 2009
    Posts
    221
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try
    PHP Code:
    <a href="scriptpage.php?action=show&id=google">google</a>
    <
    a href="scriptpage.php?action=show&id=yahoo">yahoo</a
    the scriptpage should read the variables like:

    PHP Code:
    $_GET['action'
    and
    PHP Code:
    $_GET['id'
    you can then display the page based on the inputs with if conditions.


Bookmarks

Posting Permissions

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