Posted By

erichelgesen on 06/08/09


Tagged

form select


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

silentbob84


Generate Select Box


 / Published in: PHP
 

Use this to generate a select box

  1. function generate_select($values,$selected,$usekey=''){
  2. foreach ($values as $key=>$data){
  3. if(!empty($usekey)){$option_value = $key;}
  4. else{$option_value = $data;}
  5. if($selected == $option_value){echo "<option value = '$option_value' selected>$data</option>";}
  6. else{
  7. echo "<option value = '$option_value'>$data</option>";
  8. }
  9.  
  10. }

Report this snippet  

You need to login to post a comment.