Advertisement
michaelyuen

Untitled

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