ecabrera Posted September 1, 2011 Share Posted September 1, 2011 ok basically this is part of a script and i wont whatever the user select and save to appear when they come back to edit it but it doesnt seem to be working <tr> <td>Status</td> <td><select name='status'> <option value='<?php echo $status;?>'><?php echo $status;?></option> <option value='Single'>Single</option> <option value='Married'>Married</option> <option value='Widowed'>Widowed</option> <option value='Domestic'>Domestic</option> <option value='Cohabitation'>Cohabitation</option> <option value='Divorced'>Divorced</option></select></td> </tr > Quote Link to comment https://forums.phpfreaks.com/topic/246233-whyy/ Share on other sites More sharing options...
flappy_warbucks Posted September 1, 2011 Share Posted September 1, 2011 How about: $status_array[] = "Single"; $status_array[] = "Married"; $status_array[] = "Widowed"; $status_array[] = "Domestic"; $status_array[] = "Cohabitation"; $status_array[] = "Divorced"; foreach($status_array as $k=>$v) { if (strtolower($status) == strtolower($v)) { $sel = "selected"; } else { $sel = ""; } echo "<option value=\"". $v. "\" ". $sel. ">". $v. "</option>"; } that *should* do it. Quote Link to comment https://forums.phpfreaks.com/topic/246233-whyy/#findComment-1264568 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.