I want to display selected value as selected and others list in drop down.how it is possible inforeach loop
<?php $physicaldata = explode(",",$physical);
?>
<select name="PEPhysical[]" multiple onchange="GetrestPhysical(this.value);">
<?php foreach ($physicaldata as $physical)
{?>
<option <?php if($physical == 'Normal'){ echo ' selected="selected"'; } ?> value="Normal" >Normal Person</option>
<option<?php if($physical == 'Deaf/Dumb'){ echo ' selected="selected"'; } ?> value="Deaf/Dumb">Deaf/Dumb</option>
<option<?php if($physical == 'Blind'){ echo ' selected="selected"'; } ?> value="Blind">Blind</option>
<option<?php if($physical == 'Physically Challenged'){ echo ' selected="selected"'; } ?> value="Physically Challenged">Physically Challenged</option>
<option <?php if($physical == 'Mentally Challenged'){ echo ' selected="selected"'; } ?>value="Mentally Challenged">Mentally Challenged</option>
<option <?php if($physical == 'With other Disability'){ echo ' selected="selected"'; } ?> value="With other Disability">With other Disability</option>
<?php } ?>
but now listing morethan onetime(look uploaded image)
how i can change listing value display ones.?
Either do the foreach over possible values, and check whether the value is in selected values (only one option tag in your code then since you'r printing it in a loop):
<?php foreach ($possibleValues as $possibleValue)
{?>
<option <?php
if($selectedValues[$possibleValue->id]){ echo ' selected="selected"'; }
?> value="<?php
echo $possibleValue->id
?>" ><?php
echo $possibleValue->description
?></option>
<?php } ?>
Or print them as you do, but then don't use a for loop to print them - use a loop or better an associative array to check whether each of them is selected.