Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Aug 2007
    Posts
    16
    Thanks
    3
    Thanked 0 Times in 0 Posts

    combine form fields

    Hello
    If someone could help me out with this problem it would be appreciated.

    I am trying to insert into my database a single date entry generated from three select boxes within a form. The select boxes give the options of day, month and year in the format of 01 March 2007 and each select box has the id of 'ind_date'. The corresponding database column is type DATE.

    The code I am currently using is
    PHP Code:
    $ind_date '';
    foreach(
    $_POST['ind_date'] as $value) {
      
    $ind_date .= $value ' ';
    }
    $ind_date trim($ind_date);


    $ind_date $_POST['ind_date'][0] . '' $_POST['ind_date'][1] . '' $_POST['ind_date'][2]; 
    in association with the following query

    PHP Code:
    $query "INSERT INTO opsv10 (first_name, last_name, company, position, registered, ind_date) VALUES ('$fn', '$ln', '$cn', '$pos', NOW(), '$ind_date')"
    but this keeps returning the following error

    "Invalid argument supplied for foreach()"

    All suggestions welcome.
    Thanks
    JBLC

  • #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    The name has to be "ind_date[]", not the id.

  • Users who have thanked Inigoesdr for this post:

    JBLC (08-22-2007)

  • #3
    New Coder
    Join Date
    Aug 2007
    Posts
    16
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Brilliant, problem solved.

    Top coder that man.

    JBLC


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •