从mysql数据库获取的php变量的值无法在bootstrap模态

时间:2018-01-29 06:14:42

标签: php mysql html5 html-table bootstrap-modal

我想获取mysql数据库表行并将其显示到html表之后,当用户单击表中的值,bootstrap模式触发器并显示模式中所单击行的所有列值。 这是php代码

  <tbody>
               <?php
                include "connection.php";
                $sql="SELECT email,date_t from users";
                $result=mysqli_query($conn,$sql);
                while($row=mysqli_fetch_array($result))
                {
                  $mail=$row['email'];
                  $getID = mysqli_fetch_assoc(mysqli_query($conn, "SELECT fname,email from users where email='$mail'"));
                  $fname = $getID['fname'];
                  $email = $getID['email'];
                  echo '<tr>
                  <td>'.$fname.'</td>
                  <td><a href="#" data-toggle="modal" data-target="#mymodel">'.$row['email'].'</a></td>
                  <td>'. "$email" .'</td>
                  <td>'.$row['date_t'].'</td>
                  </tr>';
                } 

                ?>

  </tbody>

这是bootstrap模式

    <div id="mymodel" class="modal fade" role="dialog">
  <div class="modal-dialog">

  <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Email Reply</h4>
      </div>
      <div class="modal-body">
        <p><?php echo $email; echo $fname; ?></p>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
      </div>
    </div>

  </div>
</div>

它会在模态中显示$ fname的值但不显示$ email的值

任何帮助将不胜感激!

0 个答案:

没有答案