php - if and else with and -


my first page checkbox form

    <!doctype html> <html> <body>  <form action="1.php" method="post"> <input type="checkbox" name="count" value="count">count<br> <input type="checkbox" name="search" value="search">search<br> <input type="checkbox" name="order" value="order">order  <input type="submit" value ="submit"> </form>  </body> </html> 

then next page collecting values using post , using if conditions displaying result

  <?php     if(empty($_post['count'])) {             $_post['count']='';          }         else {              $a=$_post['count'];          }         if(empty($_post['order'])) {             $_post['order']='';          }         else {              $b=$_post['order'];          }          if(empty($_post['search'])) {             $_post['search']='';          }         else {              $c=$_post['search'];          }         if($_post['count']=="count" && $_post['search']=="search" && $_post['order']=="order" )  {           echo  "i have count ,search , order" ;        }          else if($_post['order']=="order" && $_post['count']=="count" && $_post['search']!="search"  )  {            echo "i have order , count";         }         else if($_post['search']=="search" && $_post['count']=="count" && $_post['order']!="order"  )  {            echo "i have search , count";         }          else if($_post['search']=="search" && $_post['order']=="order" && $_post['count']!="count"  )  {            echo "i have search , order";         }                   else if($_post['count']=="count" || $_post['search']=="search" || $_post['order']=="order"  ) {           echo $_post['count'];           echo $_post['search'];           echo $_post['order'];        } ?> 

i have bike condition working

i have car condition working

i have car , bike not working , new language plz

your code newer reach last elseif statement. move last else if -statement top.

    <?     if(empty($_post['vehicle'])) {             $_post['vehicle']='';          }         else {              $a=$_post['vehicle'];          }         if(empty($_post['vehicle1'])) {             $_post['vehicle1']='';          }         else {              $b=$_post['vehicle1'];          }        if($_post['vehicle']=="bike" && $_post['vehicle1']=="car")  {           echo  "i have car , bike" ;        }          else if($_post['vehicle']=="bike") {            echo "i have bike";         }               else if($_post['vehicle1']=="car") {           echo  "i have car" ;        } ?> 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -