/ Published in: PHP
Use this to generate a select box
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function generate_select($values,$selected,$usekey=''){ foreach ($values as $key=>$data){ else{$option_value = $data;} if($selected == $option_value){echo "<option value = '$option_value' selected>$data</option>";} else{ echo "<option value = '$option_value'>$data</option>"; } }