I want to show name of the record in select, but I need to send only id of that record.
My code:
{{ Form::open(['action' => 'ZanrController@store', 'method' => 'POST']) }} <div> <label class="form-label"> <b> <a href="" data-toggle="modal" data-target="#exampleModal">Žánr *</a></b> </label> <div> <select name="druh" class="form-control"> <?php $res = mysqli_query($link, "select * from druh_lit_zanrus"); while($row = mysqli_fetch_array($res)) { ?> <option> <?php echo $row["id_druhu_lit_zanru"]; ?></option> <?php } ?> </select> </div> </div> {{Form::submit('Submit', ['class' => 'btn btn-primary'])}} {{ Form::close() }}
Advertisement
Answer
You can send selected value in option
<option value="<?php echo $row["id"]; ?>"> <?php echo $row["name"]; ?></option>