将数据库中的值分解为selectpicker foreach循环

I managed to figure out how to put the selected user id's from the a selectpicker into an array in my table column called crew_id. It is stored 12, 15, 18, ect.

What I can't figure out is how to explode the value to use in a foreach loop where the selected id's are highlighted(already ticked) in the top of the selectpicker.

$toppies and $job are 2 different tables

Here is my code for the selectpicker:

<div class="col-md-2">
    <div class="form-group">
        <label for="form_crew">Select Crew(If Known)</label>
        <select class="selectpicker form-control" multiple="multiple" size="3" name="toppies[]">
          <?php  foreach ($all_toppie as $toppies): ?>
            <option value="<?php echo $toppies['id'] ?>" <?php if($job['crew_id'] === $toppies['id']): echo "selected"; endif; ?>>
              <?php echo $toppies['name'] ?>
            </option>
          <?php endforeach; ?>
        </select>
        <div class="help-block with-errors"></div>
    </div>
</div>

Here is the sql to find all the id's.

 $all_toppie = find_all_toppie('users');
function find_all_toppie($table) {
    global $db;
    if(tableExists($table))
    {
        $sql = " SELECT id, name FROM ($table)";
        $sql .= "WHERE user_level='3'";
        $sql .= "AND status='1'";
        $sql .= "ORDER BY name ASC";
        find_by_sql($sql);
    }
}

Im not sure where to go from here and any help would be appreciated.