42 users online (1 members and 41 guests)  


  Results 1 to 3 of 3

Related

  1. If condition for moving to another page    Forum: PHP Forum
    Replies: 1
  2. Confused in using if condition    Forum: PHP Forum
    Replies: 0
  3. Replies: 2
  4. another question...    Forum: HTML Forum
    Replies: 6
  5. Another question (Yes sorry another one)    Forum: Javascript Forum
    Replies: 7
  1. #1
    newphpcoder's Avatar
    Junior Member

    Status
    Offline
    Join Date
    Sep 2010
    Posts
    52

    Question about if condition

    Good day!

    I have if condition in my code and it is for checking the input data from the user or client.

    Here is my if statement:
    PHP Code:
    if($_POST["from1_date"] && $_POST["to1_date"] && $_POST["shift1"]) 

    this code is work when i insert in the text field the from date, to date and the shift. I have 3 types of shift. For example I input from 2011-01-01 to 2011-01-02 shift 1-6 all the data that the shift is 1-6 is appear. My problem now is when i did not input shift no data was appear. I want to happen is when I did not input shift all the data from date to date will appear.

    Any help is highly appreciated.

    Thank you

  2. #2
    ALL's Avatar
    Super Dooper Nerd

    Status
    Offline
    Join Date
    Feb 2005
    Location
    localhost
    Posts
    382

    Re: Question about if condition

    PHP Code:
    if($_POST["from1_date"] && $_POST["to1_date"] && !$_POST["shift1"]) 

  3. #3
    hairtreatment's Avatar
    New User

    Status
    Offline
    Join Date
    Apr 2011
    Posts
    8

    Re: Question about if condition

    You mean if all the data will not be filled in, the data will not be inserted to the db?
    PHP Code:
    if($_POST['from1_date']=="" && $_POST['to1_date']=="" && $_POST['shift1']=="")
    {
      
    //no query;
    }
    else if(
    $_POST['from1_date']!="" && $_POST['to1_date']!="" && $_POST['shift1']!="")
    {
      
    //insert query;
    }
    else if(
    $_POST['from1_date']!="" && $_POST['to1_date']!="" && $_POST['shift1']=="")
    {
      
    //insert query; but shift data is blank.

    Last edited by HTML; 04-29-2011 at 06:05 AM.