TECHNICALSTUDY

The associate of technical study article for computer science students which could gain the knowledge about to technicals like Computer history, hard disk, printer,central processing unit etc. Technicalstudy also considered software engineering, operating system and some chunks of programming languages.

Email subscription

Enter your email address:

Delivered by FeedBurner

Sunday, October 29, 2023

Select Option Check Selected With All Options Values With using ternary Operator

 1- Most Important Point make it selected option with all option's Records  With using ternary Operator:

<div class="form-group">

<label for="cars">Choose Role:</label>
<div class="col-sm-10">
<select name="role" id="role" class="form-control">
<option value="" >Choose Roles</option>
<?php foreach($roles as $role){?>
<option value="<?= $role['id']?>"
<?php echo ($role['id'] == $data['role_id'])
? 'selected' : ''; ?>>
<?= $role['role']?>
</option>
<?php } ?>
</select>
</div>
</div

No comments:

Post a Comment

Adbox