gpt4 book ai didi

php - 数据列表在下拉列表中的空格后未显示完整名称

转载 作者:行者123 更新时间:2023-11-29 19:12:04 25 4
gpt4 key购买 nike

Datalist 未在空格后打印完整名称。它只是给出名称的第一个单词,即忽略空格后的完整名称。名称是从数据库中获取的。假设银行名称是“XYZ Global Bank”,那么它在下拉列表中仅显示“XYZ”,并且不显示其他名称。请在这里帮助我。

$query = "SELECT name FROM issuer";
$result = $conn->query($query);
if(!$result) die($conn->error);
$rows=$result->num_rows;
echo "<datalist id='bankNames'>";
for($i=0; $i<$rows; $i++)
{
$result->data_seek($i);
$row = $result->fetch_array(MYSQLI_ASSOC);
echo "<option value='".$row['name']."'>";
}
echo "</datalist>";

最佳答案

Hi, Use this code it ll resolve all your issue with the space. For your reference i have attached one image file so it ll be very help full for you.

<?php
$conn = new mysqli('localhost', 'username', 'password', 'database-name')
or die ('Cannot connect to db');
$result = $conn->query(" SELECT DISTINCT name FROM issuer;");
echo "<select name='name' class='required-entry form-control' id='name' >";
while ($row = $result->fetch_assoc()) {
unset($name);
$name = $row['name'];
echo '<option value=""></option>';
echo '<option value="'.$name.'">'.$name.'</option>';
}
echo "</select>";
?>

Image for Output how it will show.

关于php - 数据列表在下拉列表中的空格后未显示完整名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43006936/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com