CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2004
    Posts
    187

    UPDATE with array

    I have a form like this:
    Code:
    <form id="form1" name="form1" method="post" action="">
      <input type="checkbox" name="checkbox[]" id="checkbox[]" value="1" /> Item 1
      <input type="checkbox" name="checkbox[]" id="checkbox[]" value="2" /> Item 2
      <input type="checkbox" name="checkbox[]" id="checkbox[]" value="3" /> Item 3
      <input type="submit" name="button" id="button" value="Submit" />
    </form>

    When I submit (checking only the first and the third record checkboxes for example) I do a foreach and I insert only the checked records in my database:

    id value_id_ck
    1 1
    2 3

    So, when I go back to the form I see the first and the third checkboxes checked

    Now, If i uncheck the 1st and the 3rd ones and check the 2nd, how to update?
    How to know that a record was there and now I dont want it to be there anymore and I want to include new ones?

    I´d like now my database to be
    id value_id_ck
    3 2

  2. #2
    Join Date
    May 2002
    Posts
    10,943

    Re: UPDATE with array

    Your database has unique ID rows...If you're doing that, obviously you want data indexable. So, put a hidden input in the form.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured