我已根据第一个下拉选项编写了一些sql代码来输出数据库中的值,但是我可以看到通过控制台中的inspect元素返回的值,但我的文本字段为空白
<?php
$connection = mysqli_connect("localhost", "root", "");
$sn = $_REQUEST['get_option'];
mysqli_select_db($connection, "dqa");
$result = mysqli_query($connection, "SELECT * FROM action_plan WHERE sn = '".$sn."' GROUP BY site");
while($row = mysqli_fetch_array($result))
{
?>
<input type="text" name="site" value="<?php echo $row['site']; ?>">
<?php
}
mysqli_free_result($result);
mysqli_close($connection);
?>
答案 0 :(得分:0)
<?php
$connection = mysqli_connect("localhost", "root", "");
$sn = $_REQUEST['get_option'];
mysqli_select_db($connection, "dqa");
$result = mysqli_query($connection, "SELECT * FROM action_plan WHERE sn = '".$sn."' GROUP BY site");
while($row = mysqli_fetch_array($result,MYSQLI_ASSOC))
{
?>
<input type="text" name="site[]" value="<?php echo $row['site']; ?>" />
<?php
}
mysqli_free_result($result);
mysqli_close($connection);
?>
尝试将此添加的名称=“sites []”添加到数组中并获取结果中的MYSQLI_ASSOC具有关联数组还添加了< input '/'>
选择下拉:
$connection = mysqli_connect("localhost", "root", "");
$sn = $_REQUEST['get_option'];
mysqli_select_db($connection, "dqa");
$result = mysqli_query($connection, "SELECT * FROM action_plan WHERE sn = '".$sn."' GROUP BY site"); ?>
<select name="site" class="form-control" id="new_select">
<?php
while($row = mysqli_fetch_array($result,MYSQLI_ASSOC)) {
?>
<option value="<?php echo $row['site']; ?>" ><?php echo $row['site']; ?> </option>
<?php } ?>
</select>
<?php
mysqli_free_result($result);
mysqli_close($connection); ?>