I want to echo the Approve / reject instead of the value that is stored in the database. How do i achieve this in PHP?
<select name="supAprrove" id="supAprrove">
<option value="1" >Approve</option>
<option value="2">Reject</option>
</select>
One way to do it is with a ternary statement:
echo $_POST['supAprrove'] == 1 ? 'Approve' : 'Reject';
The statement is a shorthand if/else. The condition before the ?
is evaluated. If it evaluates to true
, then you get the result of the statement after the ?
, otherwise you get the result of the statement after the :
.