/ Published in: PHP
dynamically selects a value in a select according to what's already in the DB
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function selecciona($dis) { { $selected = ($arr[$i] == $dis) ? 'selected="selected"' : ''; echo "<option value=\"{$arr[$i]}\" {$selected}>{$arr[$i]}</option>\n"; } }