gpt4 book ai didi

php - 将组合框中的所选项目设置为 "please select..."

转载 作者:行者123 更新时间:2023-11-29 13:43:44 27 4
gpt4 key购买 nike

我想添加“请选择...”作为组合框中的第一个选项。请参阅下面的代码 - 有什么建议吗?

问候,彼得

<?php

mysql_connect ("localhost", "username", "password");
mysql_select_db('mysqldb');

$sql = "SELECT data_id FROM projects";
$result = mysql_query($sql);

echo "<select name='data_id '>";
$sql[0] = 'Please select...';
while ($row = mysql_fetch_array($result))
{
echo "<option value='" . $row['data_id '] . "'>" . $row['data_id'] . "</option>";
}
echo "</select>";

?>

最佳答案

替换 $sql[0] = 'Please select...';
对此 echo '<option value="" disabled>Please select...</option>';

关于php - 将组合框中的所选项目设置为 "please select...",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17734871/

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