Adding value from dropdown or textfield to one database field

Discussion in 'PHP' started by gspabla, Apr 17, 2009.

  1. #1
    Please have a look to the attachment to see what im trying to do.
    Database field= "Age"
    i want that if a user choose date of birth or if he writes his age in text box, the data goes to the fieldname 'Age ' only

    how do i do this?
    $insert = mysql_query("insert into register (Name,Gender,DOB,Age,TOB,POB) values ('".$_SESSION['Name']."', '".$_SESSION['Gender']."', '".$_SESSION['DateofBirth']."', '".$_SESSION['Age']."', '".$_SESSION['Timeofbirth']."', '".$_SESSION['Placeofbirth']."')
    
    or die("Could not insert data because ".mysql_error());
    PHP:
    im a newbie to php/mysql
    please help!
     

    Attached Files:

    gspabla, Apr 17, 2009 IP
  2. kjambu

    kjambu Peon

    Messages:
    21
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    the sql looks ok for me.
    r u not seeing the data getting inserted into the 'Age' field?
    :)
     
    kjambu, Apr 17, 2009 IP
  3. ActiveFrost

    ActiveFrost Notable Member

    Messages:
    2,072
    Likes Received:
    63
    Best Answers:
    3
    Trophy Points:
    245
    #3
    What you are trying to achieve ? You'll need to check it and execute 2 different SQL queries - one if it's empty, second if it's filled in.
     
    ActiveFrost, Apr 17, 2009 IP