I am trying to display a checked checkbox if the store has been assigned a value in the database, i have the following but am not sure why it is not working, it is currently not checking any checkboxes even though they have values assigned.
$stores = array();
$stmt = DB::query(Database::SELECT, 'SELECT `id`, `store`, `store_name`, `branch_name` FROM `mystores` WHERE `site` = :site ORDER BY `store_name` ASC, `branch_name` ASC');
$stmt->param(':site', $this->permissions['site'][0]);
try {
$result = $stmt->execute()->as_array();
if (count($result) >= 1) {
foreach ($result as $row) {
$checked = in_array($row['store'], $assigns) ? 'checked="checked"' : '';
$stores[] = '<label><input type="checkbox" name="stores['.$row['store'].']" value="'.$row['store'].'"'.$checked.' />'.$row['store'].' - '.$row['store_name'].' - '.$row['branch_name'].'</label>';
}
}
} catch (Exception $e) {
FB::error($e);
}
$row['store']and$assigns?