Welcome to PHPBuilder!
When posting PHP code, please use the board's [noparse]
..
[/noparse] bbcode tags as they make your code much easier to read and analyze.
Now, as for your issue...
sehummel wrote:When I run this, only the last item in the array is set to yes, even though all items in the array should have a session variable equal to 'Yes'. Can someone please help me
First check what values are getting passed in; do a [man]print_r/man on $accessories to see what it looks like.
sehummel wrote:Also, is there a cleaner way to do this with a switch statement?
I don't know about a switch() statement, but I'd probably use an array, e.g.:
$entities = array(
// syntax is (session array key) => (corresponding POST'd value)
'hpdfo' => 'HPDFO',
'automation' => 'Automation Interface',
// etc.
);
foreach($entities as $key => $value) {
$_SESSION[$key] = (array_search($value, $_POST['accessories']) !== FALSE ? 'Yes' : 'No');
}