Click to See Complete Forum and Search --> : UPDATE with array


rogernem
January 24th, 2011, 05:31 PM
I have a form like this:

<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

PeejAvery
January 25th, 2011, 07:44 AM
Your database has unique ID rows...If you're doing that, obviously you want data indexable. So, put a hidden input in the form.