Jump to content

whyy


ecabrera

Recommended Posts

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 >

Link to comment
https://forums.phpfreaks.com/topic/246233-whyy/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/246233-whyy/#findComment-1264568
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.