Advertisement
michaelyuen

Untitled

Oct 31st, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.69 KB | None | 0 0
  1. <?php
  2.     function selected($founders, $id) {
  3.         foreach ($founders as $founder) {
  4.                         $selected = ($founder == $id) ? ' selected' : '';
  5.                         $options[] = '<option value="'. $founder. '" '. $selected .'>';
  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.         $rowS = $stmt->fetch(PDO::FETCH_ASSOC);
  17.         // print_r($row);
  18.         foreach ($rows as $row){
  19.                 echo $row[$id];
  20.                 echo selected($founders, $row[$id]);
  21.                 echo $row[$id]."</option>";
  22.         }
  23.  
  24. ?>
  25. </select>
  26.  
  27. In above $company->founder_id = 1,2,3,4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement