Hi I am trying to make dropdown with default set based on php variable but not getting desired result please help I am a new into this
<?php
if ($_POST['search'] != '') {
$searchType = $_POST['search_type'];
}
?>
<form action="" method="POST">
<select name="search_type" id="search_type">
<option value='A' <?=(isset($searchType) && ($searchType=="A"))?'selected':'';?> >A</option>
<option value='1' <?=(isset($searchType) && ($searchType=="1"))??'selected';?> >1</option>
<option value='x' <?=(isset($searchType) && ($searchType=="x"))??'selected';?> >x</option>
<option value='y' <?php (isset($searchType) && ($searchType=="y"))??'selected';?> >y</option>
<option value='z' <?=(isset($searchType) && ($searchType=="z"))??'selected';?> >z</option>
</select>
<input type="text" name="search" id="search" placeholder="Search.. " >
</form>
question from:https://stackoverflow.com/questions/66057691/set-default-option-with-raw-php-variable-no-javascript-or-other-lib