Okay, so I have successfully retrieved rows from my db where i have fields :
ref,fname,lname,event1,event2,event3.
ref is the ID (autonumber).
So in my index php file I retrieve the data from my db and store in a table with appropiate headers and then the 100 names approx I have. For event 1 event 2 and event 3 rows i have checkboxes. Now , I’ve tried for hours to capture the checked checkboxes and update the db record columns for event1 and/or event2 and/or event3. I think my error is when i name the checkboxes, I named for each row:
The event1 checkbox I named event1[]
The event2 checkbox I named event2[]
The event3 checkbox I named event3[]
…and this was repeated a 100 times. When I submit the form, I wrote in the post_submit.php file the following:
$event1[] = $_POST['event1'];
$event2[] = $_POST['event2'];
$event3[] = $_POST['event3'];
Which is apparently wrong as it doesn’t work.
What happens is, when i check some checkboxes and then submit the form, it’s always the first couple of records in my db that gets updated, if i check the LAST checkbox for event1, and i go to my database and it was only the event1 field for the first record which got updated. I’m doing something wrong here, and i’m guessing it’s something to do with the information I have provided above. Can somebody please help. Also, for the checkbox value i have “1” so the idea is to update the event1,2,3 fields with a 1 if it was checked.
Thanks
If I understand correctly, you have a table of about 100 rows with:
and event 1-3 are just checkboxes in the table field.
If you just have event1[] with value either 1 or 0 (checked or unchecked) and you post this form, the submit screen will just have an array of 0’s and 1’s. It does not keep track of which row it comes from.
Advise: give your event1-3[] the value of the id. This way your event array will contain the id’s that need the event updated.
So if you have id = 3, then have the checkbox: