Let me present my code first (please note im a beginner)
<?php include ('header.php'); ?>
<h3>Extra menu items , van eigen pagina's</h3>
<!-- zet menu onderdelen aan of uit -->
<?php
if ($_POST['submit'] == 'Verzenden') {
$checkbox_vals = $_POST['np_menu_active_post']; // This will pass the selected checkbox values as an array
//if(count($checkbox_vals) > 0) {
// Loop it and update the values in DB
foreach( $checkbox_vals as $key ){
$updatequery = "UPDATE custompage set np_menu_active = '$key'";
mysql_query($updatequery) or die("Couldn't get file list");
}
//}
?>
<meta HTTP-EQUIV="Refresh" CONTENT="0"; URL="<?php echo $_SERVER['PHP_SELF'];?>">
<?php
}
?>
<?php
$dbQuery_custom_toggle = "SELECT * ";
$dbQuery_custom_toggle .= "FROM custompage";
$result_custom_toggle = mysql_query($dbQuery_custom_toggle) or die("Couldn't get file list");
while($row = mysql_fetch_array($result_custom_toggle)) {
// $nptitel = $row['np_titel'];
// $nptekst = $row['np_tekst'];
?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
<input type="hidden" name="np_menu_active_post[]" value="0" />
<?php echo $row['np_menu_titel'];?> <input type="checkbox" name="np_menu_active_post[]" value="1" <?php if($row['np_menu_active'] == "1"){echo 'checked="checked"';}?> /> <br />
<?php
}
?>
<input type="Submit" name="submit" value="Verzenden" class="btn-primary">
</form>
<!-- einde menu toggles -->
<br />
<br />
So im trying to make this form write the 1 value or 0 value based upon the checkboxed to the mysql db. Its partly working, when i select the last checkbox, it checks all, and writes that to the db
im new to php and mysql, so please bare with me