Select usando if/else ternário

<?php $status=3; ?>
<select name="status">
 <option <?php echo $selected = ($status == '1') ? 'selected="selected"' : ''; ?>>1 - Aguardando</option>
 <option <?php echo $selected = ($status == '2') ? 'selected="selected"' : ''; ?>>2 - Aceito</option>
 <option <?php echo $selected = ($status== '3') ? 'selected="selected"' : ''; ?>>3 - Rejeitado</option>
</select>

E tem mais ...

Gostou? Compartilhe!

Share on facebook
No Facebook
Share on twitter
No Twitter
Share on linkedin
No Linkdin
Share on pinterest
No Pinterest

Em alta!

Leave a comment