Results 1 to 5 of 5

Thread: parsing parameters passed from htm

  1. #1
    Join Date
    Jul 2005
    Posts
    101
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default parsing parameters passed from htm

    I think this should be easy but don't know how to do it.

    I want to pass in three parameters from a href to a php script like so
    <a href="showimage.php?image=image1.jpg?width=100?height=100">

    The php script should get the image and display it using the height and width parameters.

    I'm not sure if the href line is structured correctly and haven't a clue how to parse it in PHP
    Cheers
    Billy

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    First off, the link should be like so:

    Code:
    <a href="showimage.php?image=image1.jpg&amp;width=100&amp;height=100">
    Then, to get the variables in your php code, you must request them by using $_GET, $_POST, or $_REQUEST like so:

    Code:
    <?php
    
    /*assign the variables*/
    $image = $_GET['image'];
    $width = $_GET['width'];
    $height = $_GET['height'];
    
    //rest of code here
    ?>
    Hope this helps.
    Last edited by thetestingsite; 04-13-2007 at 09:27 PM.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. #3
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    No,
    Code:
    <a href="showimage.php?image=image1.jpg&amp;width=100&amp;height=100">
    & is a special character in HTML, so it has to be escaped. You can also use a semicolon (;).
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  4. #4
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    I thought that I added that, but must have erased it when putting the color to it. Anyways, thanks for pointing that out.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  5. #5
    Join Date
    Jul 2005
    Posts
    101
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    That's great, folks. Many thanks
    Cheers
    Billy

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
  •