Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/63.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将PHP变量传递给modal_Php_Mysql - Fatal编程技术网

将PHP变量传递给modal

将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

我有一个mysql数据,我调用它来显示在我的PHP表中,然后我单击了username01,我想调用username01的其他列(例如password01,id01)来显示在我的模式字段中。 这是我的密码:

PHP

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">&times;</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">&times;</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">&times;</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>
  ';           
}