SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: Multiple isset?

  1. #1
    SitePoint Zealot grantus's Avatar
    Join Date
    Apr 2003
    Location
    TX
    Posts
    120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Multiple isset?

    I have a page setup like this:

    It shows Area > Year > Month & Day > Pictures

    By default, it shows the area. I then link it like this:
    PHP Code:
    <a href=\"{$_SERVER['PHP_SELF']}?area=$whatarea\">{$row['area']}</a> 
    If they click on the area link, it gets all the years:
    PHP Code:
    if (isset($_GET['area'])) 
    And then I link it like this:
    PHP Code:
    <a href=\"{$_SERVER['PHP_SELF']}?area=$thearea&year=$year\">{$year}</a> 
    Then this is where I have a problem. I want to continue with "elseif" but is it possible to have more than one isset?

    If I do this:
    PHP Code:
    elseif (isset($_GET['year'])) 
    It obviously doesn't work, because in the previous link there's "area" and "year".

    I could just do "if" for each one, but then all the results would show as the user continues through the page.

    So my question is: how do I setup the elseif to accept "area" and "year"?

    Thanks.

  2. #2
    Dinah-Moe Humm mudshark's Avatar
    Join Date
    Dec 2003
    Posts
    1,072
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just tie them together in one elseif?
    PHP Code:
    elseif (isset($_GET['area']) && isset($_GET['year'])) 

  3. #3
    SitePoint Zealot grantus's Avatar
    Join Date
    Apr 2003
    Location
    TX
    Posts
    120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nah that doesn't work, that was the first thing I tried, that's why I'm stumped on this. I've even tried:
    PHP Code:
    elseif (isset($_GET[$area][$year])) 

  4. #4
    Dinah-Moe Humm mudshark's Avatar
    Join Date
    Dec 2003
    Posts
    1,072
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    See what happen if you put both isset() statements within brackets:
    PHP Code:
    elseif((isset($_GET['area'])) && (isset($_GET['year']))) 
    That should work. If not, show us some more code so we can see what's going on in more detail.

  5. #5
    SitePoint Enthusiast
    Join Date
    Mar 2007
    Location
    Toronto
    Posts
    58
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    When you only want 'area', you should also make sure 'year' is NOT set.

    PHP Code:
    if(isset($_GET['area']) && !isset($_GET['year'])) 
      
    //only area supplied in url
    else if(isset($_GET['area']) && isset($_GET['year']))
     
    //both area and year supplied 

  6. #6
    SitePoint Zealot grantus's Avatar
    Join Date
    Apr 2003
    Location
    TX
    Posts
    120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by 8nerd View Post
    When you only want 'area', you should also make sure 'year' is NOT set.

    PHP Code:
    if(isset($_GET['area']) && !isset($_GET['year'])) 
      
    //only area supplied in url
    else if(isset($_GET['area']) && isset($_GET['year']))
     
    //both area and year supplied 
    It works! Damn I didn't even think of that, even though I've done that in the past, LOL. Thanks for the help.


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
  •