Hello,
I was wondering if anyone could help as this has been puzzling me. I have a form with a few checkboxes on it and i need to store them in a database table taking on the following structure:
user_id / c_id
user_id being the users profile id and c_id being the category id from the checkbox on the form, so if i selected 2 checkboxes the stored information should be;
user_id / c_id
1 / 2
1 / 4
and so on.
I have tried a foreach but can't seam to get it functioning correctly, i have included my code below;
<?php
include('global.php');
dbConn();
if(isset($_POST['team']))
{
foreach($_POST['team'] as $value){
$insert=mysql_query("INSERT INTO mod_mem_cuser('user_id, c_id') VALUES ('1','$value')");
}
}
?>
<html>
<body>
<form method="post" action="add.php">
<input type="checkbox" name="team[1]" value="1"> Yoga <br />
<input type="checkbox" name="team[2]" value="2"> Blag <br />
<input type="checkbox" name="team[3]" value="3"> Shreedies <br />
<input type="submit" name="submit" value="submit">
</form>
</body>
</html>
Thanks!
Zack.