I'm working on a user creation page and i've got a few checkboxes I need to put into any array. I know how to make them an array, but have no idea how to put them into MySQL in an orderly fashion.
I was thinking about making a loop and throwing it all into one string and storing that. Then I could just parse the string and pull out what I need.
I also can't figure out how to put the data into a $_SESSION array. This is what I have at the moment.
registration.php
Code: Select all
<tr>
<td align="right">XBox </td>
<td><input name="console[]" type="checkbox" id="xbox" value="xbox" /></td>
<td><input name="genre[]" type="checkbox" id="mmorpg" value="mmorpg" />
MMORPG</td>
<td> </td>
</tr>
<tr>
<td align="right">XBox 360 </td>
<td><input name="console[]" type="checkbox" id="xbox360" value="xbox360" /></td>
<td><input name="genre[]" type="checkbox" id="rpg" value="rpg" />
Single Player RPG </td>
<td> </td>
</tr>
<tr>
<td align="right">PS2 </td>
<td><input name="console[]" type="checkbox" id="ps2" value="ps2" /></td>
<td><input name="genre[]" type="checkbox" id="fps" value="fps" />
FPS (First Person Shooter) </td>
<td> </td>
</tr>
Code: Select all
$genre = $_POST['genre'];
if($genre)
{
foreach($genre as $f) {
echo $f."<br />";
}
}else {}