我从构建器表中获取数据,并在下拉列表中显示它是代码。
<select style="width:154px;">
<?php
include('connection.php');
$show_builder = "SELECT * FROM builders";
$result_builder = mysqli_query($conn,$show_builder);
while($data_builder = mysqli_fetch_array($result_builder)){
echo"<option>".$data_builder['builder_name']."</option>";
}
?>
我想选择一个值,并将其作为id
存储在用户表格中,作为表格中的builder_id
。
答案 0 :(得分:0)
简而言之,您必须拥有name
的{{1}} attr,并将select
添加为builder_id
代码的value
attr:
option
答案 1 :(得分:0)
<?php
include('connection.php');
$show_builder = "SELECT * FROM builders";
$result_builder = mysqli_query($conn,$show_builder);
echo '<select name="builder">';
while($data_builder = mysqli_fetch_array($result_builder)){
echo'<option value="'.$data_builder['id'].'" >'.$data_builder['builder_name'].'</option>';
}
echo "</select>";
?>