I have an array with 8 different application names in it. I loop through it and check a checkbox if a user has selected that option on previous login.
foreach($appsArray as $app){
$query = " SELECT UK, SPAIN, FRANCE, BENELUX, GERMANY, SWEEDEN
FROM ".$app."
WHERE userid = ".$_SESSION['user']['id'];
$stmt = $db->prepare($query);
$result = $stmt->execute();
$result = $stmt->fetchAll();
echo("<td>".$app."</td> <td><center>
<input type = 'checkbox' name=\"".$app."[]\"".
"value =\"".$app."UK\" checked=\"".$result[0]['UK']."\"/> ");
$result="";
}
This works to an extent, however- what options I select for the first app is reflected across all of them. This must be to do with the way foreach loops in php, however I'm not sure how.
Any advice would be truly appreciated.
EDIT: just to clarify, the options I pick for one application are reflected across all application check boxes. I want them to be independent.