0
I have a form to edit the table data, it is working normally. But when loading the page is searching for the last name of the table.
I would like to know a way to load the page, come already selected the value corresponding to the data of that table.
The relations are right, Insert, delete and even update. However when I edit, instead of searching for the name of the position corresponding to the employee it looks for the last position. See:
I’m trying to do the if but it didn’t work out too well...
I added the condition to the code, if the cargo_id (Work Table) is equal to id_position (Position Table)
<?php if( $linha['cargo_id'] == $lista['id_cargo']){?>selected<?php } ?>
I did so:
<select class="form-control" name="cargo_id">
<?php
while($linha = mysqli_fetch_array($consulta_cargo,$consulta_func)){
?>
<option value="<?php echo $lista['id_cargo']?>" <?php if( $linha['cargo_id'] == $lista['id_cargo']){?>selected<?php } ?>> <?php echo $lista['nome_cargo']?></option>
<?php
}
?>
</select>
Place:
<option><?php echo $lista['nome_cargo']." - ".$linha['cargo_id']."/".$lista['id_cargo']?></option>
and see if the option that should be selected shows the values$linha['cargo_id']
and$lista['id_cargo']
equal. For example:Financeiro - 12/12
(assuming the "Financial" id is "12").– Sam
Although it is strange, if the
if
failed, the first option is that it should appear selected. See in the source code if options appearselected
. If all options haveselected
, the latter will be selected.– Sam
<option><? php echo $list['job name']." - ". $line['job name']." /". $list['job name']? ></option> did not show anything either...
– Gabriel Ramos