This will output an <input>
for every brand you have and append checked="checked"
to any of the selected.
$selected = array(2, 5);
$brands = array(1, 2, 3, 4, 5);
foreach ($brands as $brand) {
echo '<input type="checkbox" name="brand[]" value="'.$brand.'"'.(in_array($brand, $selected) ? ' checked="checked"' : '').'/>'."\n";
}
If the $brands and $selected are dynamic (for example from a MySQL database) you could do something like:
$brands = mysql_fetch_row('SELECT id FROM brand');
$selected = mysql_fetch_row("SELECT brand_id FROM user_brands WHERE user_id = '42'");
But without knowing more about your application, I cannot give a complete answer.