Php 组合框中不需要的空行

Php 组合框中不需要的空行,php,database,combobox,singleton,Php,Database,Combobox,Singleton,我正在从数据库填充combobox。到目前为止一切正常,但当我检查html结果时,combobox中的每一行都有空的选项标记。表中没有空行。我没有找到解决方案,问题只发生在这个get\u flight\u locations函数上 结果 请选择 巴库吉德 柏林TXL index.php 数据库类 您忘记了选项关闭标记中的符号。因此,它没有关闭标记,而是打开了另一个标记 这里有一个解决方案: printf( "<option va

我正在从数据库填充combobox。到目前为止一切正常,但当我检查html结果时,combobox中的每一行都有空的选项标记。表中没有空行。我没有找到解决方案,问题只发生在这个get\u flight\u locations函数上

结果


请选择
巴库吉德
柏林TXL
index.php


数据库类


您忘记了选项关闭标记中的符号。因此,它没有关闭
标记,而是打开了另一个标记

这里有一个解决方案:

           printf(
                "<option value=\"%s\">%s-%s</option>", 
                $row["city_id"], 
                $row["city_name"], 
                $row["airport_code"]
            );
printf(
“%s-%s”,
$row[“城市标识”],
$row[“城市名称”],
$row[“机场代码”]
);

您忘记了选项关闭标记中的符号。因此,它没有关闭
标记,而是打开了另一个标记

这里有一个解决方案:

           printf(
                "<option value=\"%s\">%s-%s</option>", 
                $row["city_id"], 
                $row["city_name"], 
                $row["airport_code"]
            );
printf(
“%s-%s”,
$row[“城市标识”],
$row[“城市名称”],
$row[“机场代码”]
);

非常感谢,我没想到:)非常感谢,我没想到:)
<?php

    class Database extends mysqli {
        private $db   = DB_NAME;
        private $user = DB_USER;
        private $pass = DB_PASS;    
        private $host = DB_HOST;

        private static $instance = null;

        public static function getInstance() {
            if (!self::$instance instanceof self) {
                self::$instance = new self;
            }
            return self::$instance;
        }

        private function __construct() {
            parent::__construct($this->host, $this->user, $this->pass, $this->db);
            if (mysqli_connect_error()) {
                exit('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error());
            }
            parent::set_charset('utf-8');
        }

        public function __clone() {
            trigger_error('Clone is not allowed', E_USER_ERROR);
        }

        public function __wakeup() {
            trigger_error('Deserializing is not allowed', E_USER_ERROR);
        }

        public function get_flight_locations() {
            return $this->query("select * from v_flight_location");
        }
    } 
?>
           printf(
                "<option value=\"%s\">%s-%s</option>", 
                $row["city_id"], 
                $row["city_name"], 
                $row["airport_code"]
            );