Forum Moderators: coopster
Checkboxes for each class
Pal
Sk
Bar
Gno
Person checks all that apply and I would like the values of all inserted into a row in the db.
This is my form.
<tr>
<td>War</td>
<td><input type=checkbox name='Classes[0]' value='War'></td>
<td>Mnk</td>
<td><input type=checkbox name='Classes[1]' value='Mnk'></td>
<td>Drd</td>
<td><input type=checkbox name='Classes[2]' value='Drd'></td>
<td>Mag</td>
<td><input type=checkbox name='Classes[3]' value='Mag'></td>
<td>Pal</td>
<td><input type=checkbox name='Classes[4]' value='Pal'></td>
</tr>
<tr>
<td>Ran</td>
<td><input type=checkbox name='Classes[5]' value='Ran'></td>
<td>Sha</td>
<td><input type=checkbox name='Classes[6]' value='Sha'></td>
<td>Nec</td>
<td><input type=checkbox name='Classes[7]' value='Nec'></td>
<td>Sk</td>
<td><input type=checkbox name='Classes[8]' value='Sk'></td>
<td>Brd</td>
<td><input type=checkbox name='Classes[9]' value='Brd'></td>
</tr>
<tr>
<td>Cl</td>
<td><input type=checkbox name='Classes[10]' value='Cl'></td>
<td>Enc</td>
<td><input type=checkbox name='Classes[11]' value='Enc'></td>
<td>Rge</td>
<td><input type=checkbox name='Classes[12]' value='Rge'></td>
<td>Alc</td>
<td><input type=checkbox name='Classes[13]' value='Alc'></td>
<td>Wiz</td>
<td><input type=checkbox name='Classes[14]' value='Wiz'></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table>
<tr>
<td>All Classes</td>
<td><input type=checkbox name='Classes[15]' value='All'></td>
<td>No Classes</td>
<td><input type=checkbox name='Classes[16]' value='None'></td>
</tr>
</table> When I view the db I see either the last value or "array".
Does anyone know what I should do.
Also thank you for your replies I have tried 7 different forums and none produced the results this quickly, looks like I will be sticking around.
can I insert a break or a split after every 4 values?
Sure, simply implement a loop and counter. This topic has come up quite a few times before so a quick search of this forum should produce quite a few answers for you. Here's one for starters...
Build html tables with php [webmasterworld.com]
Just use classes[] as ur value then when you go to store it do $classes=serialize($classes) and this somehow make it into a nice lil form then store this into your database.
When you extract it. do unserialize($classes) and its back into a nice array.
Not sure if you wanted to store the values of each check box seperately in the database or keep them in 1 field in the database.
Sterialize compacts the array into 1 value so if you pull them you pull the whole array at a time. Sorry if i mis-understood.
btw do not use the $trim function before you serialize..it wont work then