Public feed #890778

Mine

public text v1 · immutable
Raw Edit
·published 2008-02-04 01:55 UTC
rendered paste body
$states = ...
// states array of states with $states[0]['code'] = code of state $states[1]['name'];

// $selected_states is column that contains command separated list of states that are selection
$selected_states = split(',', $selected_states);

in html:

foreach ($states as $s): {
  echo "<input type='checkbox' name='states[]' value='{$s['code']}'";
  if (array_search($s['code'], $selected_states) !== false) {
    echo ' checked="checked"';
  }
  echo '> ' . $s['title'] . '<br>';
}


when posting back:
$selected_states = join(',', $_POST['states']);  // Gives you a value you can store in your DB

hope this helps.