我试图在用户单击所选元素上的按钮时创建一个表单。然而,当我尝试它,我点击一个按钮,它要么加载多个,要么加载1,但只显示一个值,如果这是有道理的。这里是我的代码:用PHP变量填充输入值和相关的ID
<?php
$sql = "SELECT * FROM services";
$result = $database->query($sql);
while ($row = mysqli_fetch_assoc($result)) {
$id = $row['id'];
?>
<div class="service_display">
<div class="service_header"><?php echo $row['service_name']; ?></div>
<div class="service_desc"><?php echo $row['service_desc']; ?></div>
<div class="service_options">
<button type="button" class="additional_files" id="additional_files">Edit</button>
</div>
</div>
<?php
}
?>
我按下按钮时将使用jQuery出现的形式,即时通讯试图与各自的ID,以填补值。这里是我的代码:
<div class="show-onclick">
<h3>Edditing service: <?php echo $row['service_name']; ?></h3>
<hr>
<form action="inc/save_edit.php?id=<?php echo $row['id']; ?>" class="service_editform">
<input type="text" name="service_name" value="<?php echo $row['service_name']; ?>">
<textarea><?php echo $row['service_desc']; ?></textarea>
</form>
</div>
我认为这个问题是我不知道从哪里把这些代码,如果我把它放在while循环,它的工作原理,但可以理解的,我有一个10输入栏弹出了..
,如果我把它放在while循环外,并运行一个单独的查询来填补它,其空..
谢谢你,我已经把它放在一个模态窗口中,但现在它只适用于当第一个环形物品,而不是其余.. –
RE:你的更新: - 谢谢!完美的作品。你刚刚救了我几天头痛,非常感谢。 :) –
你是最受欢迎的:-) –