bootstrap 错误 3:模态和 $_GET 我的 ID

Error with bootstrap 3: modal and $_GET my ID

您好,我正在使用 bootstrap 来更新我网站的用户配置文件,但最近我决定修改它的某些形式,但我在将用户 ID 发送到 $_GET 以检索所有配置文件时遇到了一些问题信息并用数据填充所有模式文本框。

我不知道我哪里错了,但我已经尝试用我的脚本传递它,但它还没有奏效。

我有那个错误:注意:未定义索引:mId in

这是我的代码:

这是我的模态:

<div id="exampleModal3" class="modal fade"  aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="exampleModalLabel3">Editar requisición de compras </h4>
</div>
<div class="modal-body">

<form method="POST">
<?php
$id =  $_GET['mId'];
$result = mysql_query("SELECT * FROM users WHERE id='$id'");

$row = mysql_fetch_array($result);
{
?>

<div class="form-group">
<label for="recipient-name1" class="control-label">ID:</label>
<input type="text" class="id form-control"  name="mId" id="mId" >
</div>
<div class="form-group">
<label for="recipient-name2" class="control-label">Username:</label>
<input type="text" class="username form-control" name="username" id="recipient-name2"  value="<?php echo $row['username']; ?>">
</div>
<div class="form-group">
<label for="recipient-name3" class="control-label">Firstname:</label>
<input type="text" class="firstname form-control" name="firstname" id="recipient-name3"  value="<?php echo $row['firstname']; ?>">
</div>
<div class="form-group">
<label for="recipient-name4" class="control-label">Lastname:</label>
<input type="text" class="lastname form-control" name="lastname" id="recipient-name4" value="<?php echo $row['lastname']; ?>">
</div>
<div class="form-group">
<label for="recipient-name5" class="control-label">Email:</label>
<input type="text" class="email form-control" name="email" id="recipient-name5" value="<?php echo $row['email']; ?>">
</div>
<div class="form-group">
<label for="recipient-name6" class="control-label">Password:</label>
<input type="text" class="form-control"  name="password" id="recipient-name6" >
</div>
<?php
}
?>
</div>

<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button>
<button type="submit" name="Modify" class="btn btn-primary">Guardar</button>
</div>
</form>
</div>
</div>
</div>
</div>

这是我的 table,我在其中列出了我所有的用户,以及调用我的模式的按钮。

<table class="table table-striped table-bordered table-hover" id="dataTables-example">
<thead>
<tr>
<th>ID</th>
<th>Firstname</th>
<th>LastName</th>
<th>Email</th>
</tr>
</thead>
<tbody>
<tr>
<?php
$result = mysql_query("SELECT * FROM users ORDER BY id");
while($row = mysql_fetch_array($result))
{
?>
<td>

<button type="button" class="open-AddBookDialog btn btn-xs btn-warning" data-id="<?php echo $row['id'];?>" data-toggle="modal" href="#exampleModal3" ><span class="glyphicon glyphicon-edit"></span></button>

</td>
<td ><?php echo $row['username'];?></td>
<td ><?php echo $row['firstname'];?></td>
<td ><?php echo $row['lastname'];?></td>
<td ><?php echo $row['email'];?></td>
</tr>
<?php
}
?>
</tr>
</tbody>
</table>

这是我的脚本:

<script>
$(document).on("click", ".open-AddBookDialog", function () {
var myId = $(this).data('id');
$(".modal-body #mId").val(myId);
});
</script>

我在网站上找到了答案 http://wpquestions.com/question/showChrono/id/7922 :

在modal.php

 <div class="modal-header">

 <a class="close" data-dismiss="modal">&times;</a>

 <h3>Modal header</h3>

 </div>

 <div class="modal-body">

 <?php

 $post_id = $_GET['ID'];

  echo $post_id;

 ?>

 </div>

 <div class="modal-footer">

 <a class="btn" data-dismiss="modal">Close</a>

 </div>

在我的索引中 php:

调用模态的按钮:

 <a href="modal.php?ID= WHAT ID YOU WANT " data-toggle="modal"Modal</a>

我的脚本:

  <script type="text/javascript">


  $('[data-toggle="modal"]').click(function(e) {

  e.preventDefault();

  var href = $(this).attr('href');

  if (href.indexOf('#') == 0) {

  $(href).modal('open');

  } else {

 $.get(href, function(data) {

 $('<div class="modal">' + data + '</div>').modal();

 });

}

});

</script>

希望对大家有所帮助!!!!