Results 1 to 2 of 2

Thread: how to show a link depending on script variable value

  1. #1

    Thread Starter
    Fanatic Member daydee's Avatar
    Join Date
    Jun 2001
    Location
    Canada
    Posts
    560

    how to show a link depending on script variable value

    Hi, I'm really new to PHP folks and have this line in a php script and would like to display download links on a page depending on what the variable value of item_name is.

    <?=$_POST[item_name]?>

    In VB it would be something like this:
    VB Code:
    1. link1 = "http://www.mysoftwareco.com/download1.php?"
    2. link2 = "http://www.mysoftwareco.com/download2.php?"
    3.  
    4. if item_name.Value = "Software1" then
    5. 'Show link1 on the page else
    6. Print link1
    7. Elseif item_name.value = "Software2" then
    8. 'Show link2 on the page else
    9. Print link2
    10. end if
    so is it possible to do this in php?

    Thanks in advance

    Cheers!
    Give your music collection a whole new life with PartyTime Jukebox

  2. #2
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099

    Re: how to show a link depending on script variable value

    Try something like this. If your new to PHP i suggest searching this forum for tutorials as people have posted some good links to help begginers.

    PHP Code:
    <?
    $link1 = "http://www.mysoftwareco.com/download1.php?";
    $link2 = "http://www.mysoftwareco.com/download2.php?";

    if($_POST['item_name'] == "Software1")
    {
        print $link1;
    }
    elseif($_POST['item_name'] == "Software2")
    {
        print $link2;
    }

    ?>

Posting Permissions

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



Click Here to Expand Forum to Full Width