1
            <?php 

        $mysqli = new mysqli("localhost", "root", "", "voorraad");

        $result = $mysqli->query("SELECT leverancier from leverancier");


        echo "<select id='leverancier' name='leverancier' style='width: 30%', color='black'>";
        while ($row = mysqli_fetch_array($result)) {
            echo "<option value='" . $row['leverancier'] ."'></option>";
        }
        echo "</select>";

        ?>

This is the code that I am using, the data is correctly loaded in the <select> menu, but the problem is that it is not visible. Here you can see the problem, the 20 records in the database are loaded, but not visible, I can select them, and save them in the database. But there are not visible.

2
  • option value you have put but you forget to put the option name. Commented Apr 4, 2016 at 11:45
  • replace this line echo "<option value='" . $row['leverancier'] ."'>" . $row['leverancier'] ."</option>"; Commented Apr 4, 2016 at 12:05

1 Answer 1

3

Change:

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

To

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

You simply forgot to give the option a name.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks dude! It's working now! Looking at this problem for almost 2 hours!
No problem, something like this might happen again a few more times
@SmashingJummy if you can check this as the answer this question can be closed

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.