将PHP变量传递给modal
我有一个mysql数据,我调用它来显示在我的PHP表中,然后我单击了username01,我想调用username01的其他列(例如password01,id01)来显示在我的模式字段中。 这是我的密码: PHP将PHP变量传递给modal,php,mysql,Php,Mysql,我有一个mysql数据,我调用它来显示在我的PHP表中,然后我单击了username01,我想调用username01的其他列(例如password01,id01)来显示在我的模式字段中。 这是我的密码: PHP while($row=mysqli\u fetch\u数组($result)) { 回声“; 回声“?>”; 回显“$row['name']”; 模态 &时代; 用户名 将您的模态部件置于while循环 while($row = mysqli_fetch_array($result
while($row=mysqli\u fetch\u数组($result))
{
回声“;
回声“?>”;
回显“$row['name']”;
模态
&时代;
用户名
将您的模态部件置于while循环
while($row = mysqli_fetch_array($result))
{
$id = $row['id'];
$username = $row['username'];
$ipaddress = $row['ipaddress'];
$name = $row['name'];
echo '<tr>
<td>
<a href="#?'.$id.'" onclick="document.getElementById(\'id'.$id.'\').style.display=\'block\'" style="width:auto;"><font color="blue">'.$ipaddress.'</font></a>
<div id="id'.$id.'" class="modal">
<form class="modal-content animate" method="GET" action="ipaddress.php">
<div class="imgcontainer">
<span onclick="document.getElementById(\'id'.$id.'\').style.display=\'none\'" class="close" title="Exit">×</span>
<img src="images/avatar.png" alt="Avatar" class="avatar">
</div>
<div class="container">
<label for="ipaddress"><b>Username '.$username.'</b></label>
<input type="text" pattern="[a-zA-Z0-9\s]+" name="username" value="'.$ipaddress.'" required>
</div>
</form>
</div>
</td>
<td>'.$name.'</td>
';
}
while($row=mysqli\u fetch\u数组($result))
{
$id=$row['id'];
$username=$row['username'];
$ipaddress=$row['ipaddress'];
$name=$row['name'];
回声'
&时代;
用户名“$Username”
“.$name。”
';
}
可能重复的我希望在该查询上看到一些更好的安全实践。准备好的语句。糟糕的HTML语法。
标记已被弃用,不要在
标记上使用onclick
。对于
标记,您错过了alt
属性。对于PHP代码,$id
在哪里>来自?另外,不要使用include
,而是使用require_once()
。它也应该是includes/dbconn.php
。对于模式,变量$row
未初始化。
<?php
include 'includes\dbconn.php';
$query = mysqli_query($conn,"SELECT * from devopstbl where id=$id");
$ipaddress = $row['ipaddress'];
$name = $row['name'];
$department = $row['department'];
?>
<div id="id01" class="modal">
<form class="modal-content animate" method="GET" action="ipaddress.php">
<div class="imgcontainer">
<span onclick="document.getElementById('id01').style.display='none'" class="close" title="Exit">×</span>
<img src="images/avatar.png" alt="Avatar" class="avatar">
</div>
<div class="container">
<label for="ipaddress"><b>Username <?php echo $username; ?></b></label>
<input type="text" pattern="[a-zA-Z0-9\s]+" name="username" value="<?php echo $ipaddress; ?>" required>
while($row = mysqli_fetch_array($result))
{
$id = $row['id'];
$username = $row['username'];
$ipaddress = $row['ipaddress'];
$name = $row['name'];
echo '<tr>
<td>
<a href="#?'.$id.'" onclick="document.getElementById(\'id'.$id.'\').style.display=\'block\'" style="width:auto;"><font color="blue">'.$ipaddress.'</font></a>
<div id="id'.$id.'" class="modal">
<form class="modal-content animate" method="GET" action="ipaddress.php">
<div class="imgcontainer">
<span onclick="document.getElementById(\'id'.$id.'\').style.display=\'none\'" class="close" title="Exit">×</span>
<img src="images/avatar.png" alt="Avatar" class="avatar">
</div>
<div class="container">
<label for="ipaddress"><b>Username '.$username.'</b></label>
<input type="text" pattern="[a-zA-Z0-9\s]+" name="username" value="'.$ipaddress.'" required>
</div>
</form>
</div>
</td>
<td>'.$name.'</td>
';
}