this may be a simple question but am struggling to understand how to solve it. I have a form which allows the user to select either \"custom\" or \"all\" staff\" to assign t
You need to give fetchAll a fetch style
$staff = $select->fetchAll(PDO::FETCH_NUM);
From this link
Take a look at example 2 in the manual. In your first query you can use:
$staff = $select->fetchAll(PDO::FETCH_COLUMN, 0);
And your second array will have the same form as the first array.
If you print_r($staff[$i])
inside the for
you would probably get
Array
(
[staffID] => 1
[0] => 1
)
which means you should use $staff[$i]['staffID']
instead.
The other alternative, which should work with your current code, is to use PDOStatement::fetchColumn() instead of fetchAll()
.