Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function selected($founders, $id) {
- foreach ($founders as $founder) {
- $selected = ($founder == $id) ? ' selected' : '';
- $options[] = '<option value="'. $founder. '" '. $selected .'>';
- }
- return implode('', $options);
- }
- ?>
- <select class="select2" name="founder_id[]" multiple="multiple">
- <?php
- $founders = explode(",",$company->founder_id);
- // print_r($founder);
- $stmt = $person->read();
- $rows = $stmt->fetch(PDO::FETCH_ASSOC);
- // print_r($row);
- foreach ($rows as $row){
- echo $row[$id];
- echo selected($founders, $row[$id]);
- echo $row[$id]."</option>";
- }
- ?>
- </select>
- // In above $company->founder_id = 1,2,3,4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement