if elseif not working

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • amrhi
    New Member
    • Sep 2006
    • 22

    if elseif not working

    Hy guys , I try to make conditional statement by using if and elseif .
    the problem are if i use 2 conditional statement the script run well but if try add more conditinal statement it's not working only 2 conditional it select.
    thanks to help me
    my script
    [PHP] //condtional//
    if ($ttl_dur > 10 and $bay!=$stand and $dpt_reg[categori]==0){
    $fail=1;
    }elseif($ttl_du r > 15 and $bay==$stand and categori==0){
    $fail=1;
    }elseif($ttl_du r > 20 and $bay!=$stand and $dpt_reg[categori]==1){
    $fail=1;
    }elseif($ttl_du r > 25 and $bay==$stand and categori==1){
    $fail=1;
    }elseif($ttl_du r2 > 20 and $dpt_reg[categori]==0){
    $fail=1;
    }elseif($ttl_du r2 > 25 and $bay==$stand and categori==0){
    $fail=1;
    }elseif($ttl_du r2 > 40 and $dpt_reg[categori]==1){
    $fail=1;
    }elseif($ttl_du r2 > 45 and $bay=="r61" and $dpt_reg[categori]==1){
    $fail=1;
    }else{
    $fail=0;} [/PHP]
  • code green
    Recognized Expert Top Contributor
    • Mar 2007
    • 1726

    #2
    but if try add more conditinal statement it's not working
    It's not working is not enough information! Why is it not working? Syntax, logic. Are you getting errors? If not you should be.

    Comment

    • Purple
      Recognized Expert Contributor
      • May 2007
      • 404

      #3
      I have taken a look at your code and given the sparse detail on your error I am assuming you want the test to happen at every elseif level - whilst elseif will nest, the first elseif expression (if any) that evaluates to TRUE would be executed only - If I have got the wrong end of the stick supply additional info on your problem..

      Comment

      • pbmods
        Recognized Expert Expert
        • Apr 2007
        • 5821

        #4
        Is categori a constant or a variable? Should it be $categori instead?

        Comment

        Working...