Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. <?php
  2.  
  3. function WriteData($start, $end, $label, $name, $array, $default = 'choose')
  4. {
  5. echo <<< W1
  6. <label for="$name">$label</label>
  7. <select name="$name" id="$name">
  8. <option value="choose">choose</option>
  9. W1;
  10. for(;$start<$end;$start++)
  11. {
  12. $number = $start ;
  13. if($start==$default)
  14. {
  15. echo '<option value="'.$number.'">'.$start.'</option>';
  16. }
  17. else
  18. {
  19. echo '<option value="'.$number.'">'.$start.'</option>';
  20. }
  21. }
  22.  
  23.  
  24. if($array[$start] === $default)
  25. {
  26. echo '<option value="'.$array[$start].' selected">'.$array[$start].'</option>';
  27. }
  28. else
  29. {
  30. echo '<option value="'.$array[$start].'">'.$array[$start].'</option>';
  31. }
  32.  
  33. echo "</select>";
  34.  
  35.  
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement