I am trying to manipulate my html select function through PHP. and I can't concatenate my PHP with html
What I am doing: When I select a drop down function it load the option of the selected field.
Problem: When I load the field the option that I chose get unselected.
what I am doing: So what I am doing is pass a If statement
to check it is true or not.
This is my code:
$result.='
<div class="form-group">
<label class="col-sm-2 control-label">Expenses Type:</label>
<div class="col-sm-4" >
<select name="expenses" style="width:285px;" class="form-control" onchange="submit(this.value)" >
<option value="0" selected="selected">Select Type</option>
<option value="3" '.if($expenses==3) {.' selected="selected" '.}.'>Other Expenses</option> /*this is the line of error*/
<option value="4" >Salary</option>
</select>
</div>
</div>';
Someone tell me to use ternary expression but I don't know how.