lundi 19 janvier 2015

Catch selected checkboxes and turn them in to variables in php

I'm stuck with the following:

I have 2 rows of checkboxes with different names.

HMTL Example:



<form action="" method="POST" enctype="multipart/form-data">
<div id="firstrow">
<input type="checkbox" name="first" value="1">1
<input type="checkbox" name="first" value="2">2
<input type="checkbox" name="first" value="3">3
<input type="checkbox" name="first" value="4">4
</div>
<div id="secondrow">
<input type="checkbox" name="second" value="1">1
<input type="checkbox" name="second" value="2">2
<input type="checkbox" name="second" value="3">3
<input type="checkbox" name="second" value="4">4
</div>
</form>


The user is only allowed to select 2 checkboxes per row of checkboxes (I found a small JS code that allows me to do this).

In total they will have selected 4 checkboxes, now I want to enter all 4 of these values in to a database in separate columns.

Now I have looked up ways to convert these values in to variables, I came across one which looped a little script that checked if each checkbox was checked or not, but in the end none of all that worked the way I wanted it to.

At the moment I'm completely stuck at this point, but I'm sure there might be a somewhat easy solution to this problem that I'm completely looking over!

Now I'm asking if anybody can help me with a couple of tips or perhaps a few search terms that I could try to get me going on this problem again.


Thanks a lot in advance!

If you need more information on this problem please ask!





Aucun commentaire:

Enregistrer un commentaire