列出时显示Accent

时间:2018-05-02 10:18:11

标签: php mysql drop-down-menu

我在PHP中有一个从MySQL中检索数据的选择框,但带有重音符号的数据会显示特殊字符。在我添加选择框之前一切都很好。我该如何解决?

这是我的代码:

<html>
    <head>
    <meta charset="utf-8">
        <!-- importer le fichier de style -->
        <link rel="stylesheet" href="Style/style1.css" media="screen" type="text/css" />
        <title>Ajouter un Scanner </title>
        <body>
        <div id="container">
            <!-- zone de connexion -->

            <form   action ="insert.php" method="post">
                <h1>Ajout d'un Scanner</h1>
                <label><b>Catégorie</b></label><br>
                <?php
                $mysqli = new mysqli("localhost", "root", "", "mapbdd") or die($this->mysqli->error);
                $query = $mysqli->query("SELECT icone_categorie FROM markers_icone");
                //$result = mysqli_query($query);
                ?>
                <select name="select_categorie" id='select_categorie'type="List" >
                  <option value="-1"></option>
                <?php
                while($row =  $query->fetch_array(MYSQLI_ASSOC)){
                  echo "<option>{$row['icone_categorie']}</option>";
                }
                ?>
                </select>
                <br><br>
                <label><b>Ville</b></label>
                <input type="text" placeholder="Entrer la ville" name="fville" required>

                <label><b>Longitude</b></label>
                <input type="text" placeholder="Entrer la longitude" name="flong" required>

                <label><b>Latitude</b></label>
                <input type="text" placeholder="Entrer la latitude" name="flat" required>

                <label><b>Description</b></label>
                <input type="text" placeholder="Description" name="fdesc" required>

                <input type="submit" id='submit' value='Insérer' >

            </form>
        </div>


    </body>
    </head>

谢谢

1 个答案:

答案 0 :(得分:0)

尝试插入此

$mysqli->set_charset("utf8");
之后

$mysqli = new mysqli("localhost", "root", "", "mapbdd") or die($this->mysqli->error);

(设置mysqli连接的字符集)