What I am trying to achieve here is giving the user the ability to select one or all of the categories that a page will display on. The user would check any combination of 3 checkboxes and a variable will be computed and saved to the database. The values are then retrieved from the database and the checkboxes are echo'd checked accordingly. What's happening is when more then 1 checkbox is checked only the latter value is saved e.g. if A and B are checked, only B is saved, or when A, B and C are checked, only C is saved. If just 1 checkbox is saved it's fine.
The PHP
<?php
if(isset($_POST['submit'])){
if ($_POST['catA'] == "a" && $_POST['catB'] == "b" && $_POST['catC'] == "c"){
$pageCat = "abc";
}
if ($_POST['catA'] == "a" && $_POST['catB'] == "b"){
$pageCat = "ab";
}
if ($_POST['catA'] == "a" && $_POST['catC'] == "c"){
$pageCat = "ac";
}
if ($_POST['catB'] == "b" && $_POST['catC'] == "c"){
$pageCat = "bc";
}
if ($_POST['catA'] == "a"){
$pageCat = "a";
}
if ($_POST['catB'] == "b"){
$pageCat = "b";
}
if ($_POST['catC'] == "c"){
$pageCat = "c";
}
}
?>
ifyou should useif .. else.$pageCat = $_POST['catA'].$_POST['catB'].$_POST['catC']