I do this in my "form" to list in a "Combobox" the places that are registered in the database:
<select class="form-control input-sm" name="cbEditarVagas" id="cbEditarVagas">
<option disabled selected>Selecione</option>
<?php
mysqli_select_db($db, $connect);
//Listar os grupos na listbox
$result = mysqli_query($connect, "SELECT id, titulo_vaga FROM tabela_cadastro_vagas ORDER BY titulo_vaga");
while ($row = mysqli_fetch_array($result)) {
$titulo_vaga = str_replace("?","",$row{"titulo_vaga"});
echo "<option value='".$row{'id'}."'>$titulo_vaga</option>";
}
?>
</select>
I use the $ _POST variable to get this id on the PHP side
$id = $_POST['cbEditarVagas'];
I wonder if they are doing this correctly, and what would be the best way?