Database: Multiple checked records in a separate table

Sorry to be a pain, i really feel i should know this but i just don’t seem to be able to get it to work

I have a server connect form which dynamically produces around 60 check boxes name: fid[].
On submission this runs a server connect action which loops through the elements in the collection sent (fid[]).
Each element has a unique value set relating to a specific checkbox.
My server action successfully loops through the elements and inserts an entry into a table for each checkbox sent i.e. if six boxes are checked, 6 records are inserted.

However my problem is how do i reference the value of each checkbox in the collection to insert that value into one of the table fields within a server connect query ?

($_POST.fid produces an error “Array to string conversion” and no records are created)

Can be seen at

Hi Brian, sorry but I am not quite sure I understand what are you trying to achieve, by your explanation:

OK, i have 60 checkboxes, each relate to a separate facility within a building.
Summarising the boxes are name=fid[] value=x where x is between 1 and 60
Obviously only those boxes checked are found in the collection when submitted from the form.
So if i check 6 boxes the collection should contain 6 elements which it does and the repeat in the server connect action repeats 6 times (i can use a blank insert to confirm this)
However i want to update a table field with the value of the checkbox (a number between 1 and 60) within that server connect loop
for example if i check the boxes corresponding to values 1,5,8,10 & 12 the server action repeats 5 times and in each case when i insert a record and i want to set a field to one of those values i.e. 5 records containing one of each of the values 1,5,8,10 & 12 like this. So how do i select the value from the checkbox


Confused? Probably not as much as me

1 Like

Brian, I place all of the checked values into one database field.

In my case I have a list of accessories contained in the accessories (uitrusting) database table. The form field is populated by this list and automatically checked when the same value has been found in the main caravan (occasion) table.

This is what the form input looks like

I hope this helps.

Thanks @ben, similar idea to me. I think the form end is OK as the submission seems to send the correct number of values, if i repeat in the server connect action on (in my case) $_POST.fid i get the correct number of repeats. My problem is extracting each value of the associated checkbox from the fid[] array sent for the insert query.
MY server action is:

My problem is identifying how to to insert the associated value into the table. This doesn’t work.

How do you want to insert them? Each in a new row, or all of them in one field, comma separated?

each in a new row

Brian, essentially in your server connect action for updating the checked selection, you need two things:

  1. Delete all checked records for the order record
  2. Loop through the id’s and Insert checked records

You just have to make sure have selected the $_POST.fid as loop expression and inside it, the current id of the repeater, you can access it with $value

Thanks for the suggestion @George,
Solved it finally
Using $value in the insert stage was the answer (as below):

1 Like

yes that was it :slight_smile:

Btw if you do delete - you can optimize it with filter NOT IN
So delete all previously checked records - that are not IN the new selection.

Good suggestion. Fortunately there is another field BuildingID identifying the building to which each facilities belong so the delete is simple, just
DELETE FROM facilitylink WHERE BuildingID = $_POST.BuildingID
followed by multiple inserts of
INSERT INTO facilitylink (BuildingID, FacilityID) VALUES ($_POST.BuildingID, $value)

it was the $value bit i missed, kicking myself now, should have spotted that before asking, sorry
Got it fully operational now, thanks for your help