我该如何启动它?我知道我需要进行 mysql 查询,但是如何转换数据,在下拉列表中的选项中。请记住,它位于表单内,用于发送 MySQL 表的结果。
(编辑)
我正在 printf 中工作,这就是我想要的:
<?php ob_start();
include('/../../config.php');
if(isset($_POST['edit_id']) && !empty($_POST['edit_id'])) {
$edit_id = mysql_real_escape_string($_POST['edit_id']);
$result = mysql_query("SELECT username, password, nome, cidade, pais, base, isactive, admin, dov, checador, dinheiro, email, datanascimento, profissao, idivao, idvatsim, horas, rank FROM acars_users WHERE `id`='".$edit_id."'");
$resultdl = mysql_query("SELECT * FROM acars_hubs");
$data = mysql_fetch_array($result);
$dl = mysql_fetch_array($resultdl);
printf("<div align=\"center\">
<br><form method=\"post\" action=\"editar2.php\">
<p><font size=\"2\" face=\"Segoe UI, Arial, Helvetica, sans-serif\" align=\"center\">Modifique os campos que deseja para <strong>editar este membro.</font><br>
<br>
<table width=\"700\" border=\"0\" align=\"center\" >
<tr>
<td>Base Operacional:</td>
<td><label for=\"hub\"></label>
<select name=\"hub\">
<option>".$dl['name']."</option>
</select>
</td>
</td>
</tr>
</table></br></br>
<input name=\"edit_id\" value=\"$edit_id\" type=\"hidden\">
<input type=\"image\" src=\"img/Editar.PNG\" width='85' height='30'></form>
</form>
</table>
</div>
");
while ($data = mysql_fetch_array($result));
while ($dl = mysql_fetch_array($resultdl));
ob_end_flush();
?>
最佳答案
你的意思是这样吗?
<select>
<?php while($row = mysql_query("SELECT * FROM table")){ ?>
<option><?=$row['column']; ?></option>
<?php } ?>
</select>
关于php - 获取表单中包含 MySQL 数据的下拉列表数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14177703/