I have a this html:
<option value="yes">Yes</option>
<option value="no">No</option>
and my php:
<?php
exec('uci get sms_gateway.setting.filter',$filt);
echo '<form action='.$_SERVER['PHP_SELF'].' method="post">
<select name="filter">';
foreach ($filt as $value){
if ($filt = "yes"){
echo '<option value="'.$value.'" selected>Yes</option><br>
<option value="no">No</option><br>ini yes';}
else {
echo '<option value="yes">Yes</option><br>
<option value="'.$value.'" selected>No</option><br> ini no';
}
}
echo '
</select>
<input type="submit" name="submit" value="Submit">';
if(isset($_POST['submit'])){
{
$data = $_POST['filter'];
echo "<br>halo ". $data;
}
}
?>
the $filt only has one string it's either yes or no
when it's yes I want the yes part on the dropdown menu selected, but when it's no I want the no part on the dropdown selected. How should I do that?
if ($filt = "yes"){rather than a comparisonif ($filt == "yes"){noon the dropdown list becomesyeswhile it should staynoforeach ($filt as $value)you're doingas $valueso tryforeach ($filt as $value){ if ($value == "yes"){