Füllen Sie HTML <select> mit Array-Daten aus MySQL in PHP

Ich kann sehen, dass die Abfrage Ergebnisse zurückgibt, aber ich kann sie scheinbar nicht in ein HTML-Dropdown-Feld einfügen. Außerdem enthält das Dropdown-Feld genau so viele Einträge wie die Abfrage zurückgibt, aber SIE SIND ALLE WEISSEN LEERZEICHEN. Die Seitenquelle zeigt jedoch die korrekten Optionswerte wie

<option value="3 John"></option>

<option value="Jude"></option>

<option value="Revelation"></option>

Kann mir jemand helfen? Warum werden sie nicht in der Dropdown-Box angezeigt?

<html>
<?php
    //Connect to the database
    $mysqli = new mysqli("localhost", "root", "", "bible");

    //Return an error if we have a connection issue
    if ($mysqli->connect_error) {
        die('Connect Error (' . $mysqli->connect_errno . ') '
                . $mysqli->connect_error);
        }

    //Query the database for the results we want
    $query = $mysqli->query("select distinct bname as Name from kjv limit 1");

    //Create an array  of objects for each returned row
    while($array[] = $query->fetch_object());

    array_pop($array);

    //Print out the array results
    print_r($array);
    ?>
    <h3>Dropdown Demo Starts Here</h3>
    <select name="the_name">
    <?php foreach($array as $option) : ?>
        <option value="<?php echo $option->Name; ?>"></option>
    </select>
        <?php endforeach; ?>

Antworten auf die Frage(5)

Ihre Antwort auf die Frage