Php 如何将下拉列表插入表格单元格?
是否可以将下拉列表插入表格单元格 谢谢大家! 下面是一些代码:Php 如何将下拉列表插入表格单元格?,php,html,css,Php,Html,Css,是否可以将下拉列表插入表格单元格 谢谢大家! 下面是一些代码: $sql_query="SELECT nameOfwarning FROM warnings"; $sodss=mysqli_query($d,$sql_query); if (mysqli_num_rows($result)<1) ?> <select name = "warnings"> <option value="Choose one of the warnings: " &l
$sql_query="SELECT nameOfwarning FROM warnings";
$sodss=mysqli_query($d,$sql_query);
if (mysqli_num_rows($result)<1)
?>
<select name = "warnings">
<option value="Choose one of the warnings: " </option>
<?php
while ($row = mysqli_fetch_array($warnings)) {
print "<option value=";
print $row["id_warning"];
print ">" ;
print $row["warning"];
print "</option>";
}
?>
</select><br>
<?php
print "<tr><td>Insert drop down list here?: </td><td><input type=\"text\" name=\"OR HERE\"></td></tr>";
$sql\u query=“选择来自警告的警告名称”;
$sodss=mysqli\u查询($d,$sql\u查询);
if(mysqli_num_行($result)
我还冒昧地格式化了您的代码。希望您不介意。您应该这样做作为一种常规做法,以使其更具可读性
<?php
$sql_query = "SELECT id_warning, warning FROM warnings";
$result = mysqli_query($d, $sql_query);
$dropDownHtml = '';
if (mysqli_num_rows($result) > 0) {
$dropDownHtml .= '<select name = "warnings">';
$dropDownHtml .= '<option value="Choose one of the warnings: " </option>';
while ($row = mysqli_fetch_array($result)) {
$dropDownHtml .=
'<option value="{$row["id_warning"]}">' .
$row["warning"] .
'</option>';
}
$dropDownHtml .= '</select><br>';
}
?>
<tr>
<td><?php echo $dropDownHtml; ?></td>
<td><input type=\"text\" name=\"OR HERE\"></td>
</tr>
看起来您跳过了一些代码,因为SQL查询应该返回的内容与结果数组不匹配,而且还有一些变量不匹配。我对其进行了一些更改,以使其看起来可信,如果您不想发布问题中的所有代码,您应该确保将其调整回您的特定情况