Advertisement
michaelyuen

Untitled

Oct 31st, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.73 KB | None | 0 0
  1. <?php
  2.     function selected($founders, $id, $name) {
  3.         foreach ($founders as $founder) {
  4.                         $selected = ($founder == $id) ? ' selected' : '';
  5.                         $options[] = '<option value="'. $founder. '" '. $selected .'>'.$name.'</option>';
  6.         }
  7.                 return implode('', $options);
  8.     }
  9. ?>
  10. <select class="select2" name="founder_id[]" multiple="multiple">
  11. <?php
  12.         $founders = explode(",",$company->founder_id);
  13.  
  14.         // print_r($founder);
  15.         $stmt = $person->read();
  16.         while ($row = $stmt->fetch(PDO::FETCH_ASSOC)){
  17.             extract($row_f);
  18.             // print_r($row);
  19.             echo $row[$id];
  20.             echo selected($founders, $row[$id], $row['screenname']);
  21.             echo $row[$id]."</option>";
  22.         }
  23. ?>
  24. </select>
  25.  
  26. // In above $company->founder_id = 1,2,3,4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement