Select HTML using database data is empty

Asked

Viewed 50 times

-1

I did select and in the database when register the value of select saved normally, but at the time of selection is not displayed.

inserir a descrição da imagem aqui

CODE

<label for="exampleFormControlInput1">Fornecedor</label>
        <select class="form-control" name="fornecedor">
           <option>Selecione o Fornecedor</option>
           <?php
            $result = "select nm_forn from tb_fornecedor";
            $resultado = mysqli_query($connection, $result);

            while($row = mysqli_fetch_assoc($resultado)) {
              echo '<option value="'.$row['nm_forn'].'"></option>';
            }
           ?>
        </select>

2 answers

3


When you do the database search you set the value of the select option, but did not put what will be displayed. Your code should be something like:

echo '<option value="'.$row['nm_forn'].'">'.$row['nm_forn'].'</option>';

Where did I put the $row['nm_forn'] which is not in your code should go the text of the option, it can be anything, I put what I would infer based on your code.

-2

777- Your echo is simply in value, you should also echo in Option

<option value=<?=Seu Resultado?>> <?=Seu Resultado?> </option>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.