SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Non-Member
    Join Date
    Jan 2004
    Location
    Seattle
    Posts
    4,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    IF with two variables

    I have a database that stores the dates various public officials held office. The dates fall into three categories:

    $TermB - the year their term began
    $TermE - the year their term ended
    $TermM - any particular year they happened to occupy office; I display this if I lack more detailed information

    Ideally, I want to display this:

    1978-1982

    But if I have just the beginning date, my display looks like this:

    1978-

    If I only had the ending date, it would look like this:

    -1982

    And if I don't know when their term began or ended, but I do know that they held office in 1980, I might display something like this:

    ?-1980-?

    The script below handles situations where I have both a beginning and ending date, a beginning date only or neither a beginning or ending date. How can I modify it so that it also handles situations where I have an ending date only?

    In other words, how can I change it so the first line says "If either $TermB OR $TermE is not empty...?

    Thanks.

    PHP Code:
    if($TermB -- !'')
     { 
    $Term ''.$TermB.'-'.$TermE.''; }
    else
     { 
    $Term $TermM; } 

  2. #2
    SitePoint Evangelist
    Join Date
    Aug 2005
    Posts
    453
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    iF ( !empty(TermB) || !empty(TermE) ){

    /* Your processing code goes here */


    Computers and Fire ...
    In the hands of the inexperienced or uneducated,
    the results can be disastrous.
    While the professional can tame, master even conquer.

  3. #3
    Non-Member
    Join Date
    Jan 2004
    Location
    Seattle
    Posts
    4,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks.


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
  •