mysql php jquery 隐藏显示 select
mysql php jquery hide show select
我懂一点 PHP 编程,但是 none JQuery。
我用来自 MySql 数据库的数据构建了一个 <select>
下拉菜单。
但现在我想要 <select>
选项旁边的按钮或其他东西,例如 + 号或会给我额外 <select>
选项的东西。而且你想来多少次都可以。
Ps。我很抱歉我的英语。
这是一张我想要的照片。
接下来你会得到这个。
这是我已经制作的代码。
<?php
$conn = new mysqli('localhost', 'username', 'password', 'database')
or die ('Cannot connect to db');
$result = $conn->query("select id, name from table");
echo "<html>";
echo "<body>";
echo "<select name='id'>";
while ($row = $result->fetch_assoc()) {
unset($id, $name);
$id = $row['id'];
$name = $row['name'];
echo '<option value="'.$id.'">'.$name.'</option>';
}
echo "</select>";
echo "</body>";
echo "</html>";
?>
您可以使用复选框代替下拉菜单进行多选
while ($row = $result->fetch_assoc()) {
unset($id, $name);//use if you want
$id = $row['id'];
$name = $row['name'];
echo '<input name="city[]" type="checkbox" value="'.$name.'" />'.$name;
}
我懂一点 PHP 编程,但是 none JQuery。
我用来自 MySql 数据库的数据构建了一个 <select>
下拉菜单。
但现在我想要 <select>
选项旁边的按钮或其他东西,例如 + 号或会给我额外 <select>
选项的东西。而且你想来多少次都可以。
Ps。我很抱歉我的英语。
这是一张我想要的照片。
接下来你会得到这个。
<?php
$conn = new mysqli('localhost', 'username', 'password', 'database')
or die ('Cannot connect to db');
$result = $conn->query("select id, name from table");
echo "<html>";
echo "<body>";
echo "<select name='id'>";
while ($row = $result->fetch_assoc()) {
unset($id, $name);
$id = $row['id'];
$name = $row['name'];
echo '<option value="'.$id.'">'.$name.'</option>';
}
echo "</select>";
echo "</body>";
echo "</html>";
?>
您可以使用复选框代替下拉菜单进行多选
while ($row = $result->fetch_assoc()) {
unset($id, $name);//use if you want
$id = $row['id'];
$name = $row['name'];
echo '<input name="city[]" type="checkbox" value="'.$name.'" />'.$name;
}